[svn:parrot] r39498 - in trunk: compilers/imcc include/parrot src src/interp

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jun 10 18:36:22 UTC 2009


Author: NotFound
Date: Wed Jun 10 18:36:20 2009
New Revision: 39498
URL: https://trac.parrot.org/parrot/changeset/39498

Log:
[cage] redoing of changes in r39493 with less loss of constness

Modified:
   trunk/compilers/imcc/imc.h
   trunk/compilers/imcc/main.c
   trunk/compilers/imcc/parser_util.c
   trunk/include/parrot/imcc.h
   trunk/include/parrot/interpreter.h
   trunk/src/interp/inter_misc.c
   trunk/src/main.c

Modified: trunk/compilers/imcc/imc.h
==============================================================================
--- trunk/compilers/imcc/imc.h	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/compilers/imcc/imc.h	Wed Jun 10 18:36:20 2009	(r39498)
@@ -236,13 +236,13 @@
         FUNC_MODIFIES(*error_message);
 
 PARROT_CANNOT_RETURN_NULL
-void * IMCC_compile_file(PARROT_INTERP, ARGIN(char *s))
+void * IMCC_compile_file(PARROT_INTERP, ARGIN(const char *s))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
 void * IMCC_compile_file_s(PARROT_INTERP,
-    ARGIN(char *s),
+    ARGIN(const char *s),
     ARGOUT(STRING **error_message))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)

Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/compilers/imcc/main.c	Wed Jun 10 18:36:20 2009	(r39498)
@@ -44,7 +44,7 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 static void compile_to_bytecode(PARROT_INTERP,
-    ARGIN(char * const sourcefile),
+    ARGIN(const char * const sourcefile),
     ARGIN_NULLOK(const char * const output_file))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -923,8 +923,8 @@
 
 /*
 
-=item C<static void compile_to_bytecode(PARROT_INTERP, char * const sourcefile,
-const char * const output_file)>
+=item C<static void compile_to_bytecode(PARROT_INTERP, const char * const
+sourcefile, const char * const output_file)>
 
 Compile source code into bytecode (or die trying).
 
@@ -934,7 +934,7 @@
 
 static void
 compile_to_bytecode(PARROT_INTERP,
-                    ARGIN(char * const sourcefile),
+                    ARGIN(const char * const sourcefile),
                     ARGIN_NULLOK(const char * const output_file))
 {
     ASSERT_ARGS(compile_to_bytecode)
@@ -955,7 +955,7 @@
     Parrot_pbc_load(interp, pf);
 
     IMCC_push_parser_state(interp);
-    IMCC_INFO(interp)->state->file = sourcefile;
+    IMCC_INFO(interp)->state->file = strdup(sourcefile);
 
     emit_open(interp, per_pbc, per_pbc ? NULL : (void*)output_file);
 
@@ -1003,7 +1003,8 @@
 
 /*
 
-=item C<int imcc_run(PARROT_INTERP, char *sourcefile, int argc, char **argv)>
+=item C<int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, char
+**argv)>
 
 Entry point of IMCC, as invoked by Parrot's main function.
 Compile source code (if required), write bytecode file (if required)
@@ -1014,7 +1015,7 @@
 */
 
 int
-imcc_run(PARROT_INTERP, ARGIN(char *sourcefile), int argc,
+imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,
         ARGIN(char **argv))
 {
     int                obj_file;

Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/compilers/imcc/parser_util.c	Wed Jun 10 18:36:20 2009	(r39498)
@@ -59,7 +59,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static void * imcc_compile_file(PARROT_INTERP,
-    ARGIN(char *fullname),
+    ARGIN(const char *fullname),
     ARGOUT(STRING **error_message))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -885,8 +885,8 @@
 
 /*
 
-=item C<static void * imcc_compile_file(PARROT_INTERP, char *fullname, STRING
-**error_message)>
+=item C<static void * imcc_compile_file(PARROT_INTERP, const char *fullname,
+STRING **error_message)>
 
 Compile a file by filename (can be either PASM or IMCC code)
 
@@ -896,7 +896,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static void *
-imcc_compile_file(PARROT_INTERP, ARGIN(char *fullname),
+imcc_compile_file(PARROT_INTERP, ARGIN(const char *fullname),
         ARGOUT(STRING **error_message))
 {
     ASSERT_ARGS(imcc_compile_file)
@@ -939,8 +939,12 @@
     interp->code                     = NULL;
 
     IMCC_push_parser_state(interp);
-    IMCC_INFO(interp)->state->file = fullname;
-    ext                            = strrchr(fullname, '.');
+    {
+        /* Store a copy, in order to know how to free it later */
+        char *copyname = strdup(fullname);
+        IMCC_INFO(interp)->state->file = copyname;
+        ext                            = strrchr(copyname, '.');
+    }
     IMCC_INFO(interp)->line        = 1;
 
     /*
@@ -998,7 +1002,7 @@
 
 /*
 
-=item C<void * IMCC_compile_file(PARROT_INTERP, char *s)>
+=item C<void * IMCC_compile_file(PARROT_INTERP, const char *s)>
 
 Note: This function is provided for backward compatibility. This
 function can go away in future.
@@ -1009,7 +1013,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 void *
-IMCC_compile_file(PARROT_INTERP, ARGIN(char *s))
+IMCC_compile_file(PARROT_INTERP, ARGIN(const char *s))
 {
     ASSERT_ARGS(IMCC_compile_file)
     STRING *error_message;
@@ -1018,7 +1022,7 @@
 
 /*
 
-=item C<void * IMCC_compile_file_s(PARROT_INTERP, char *s, STRING
+=item C<void * IMCC_compile_file_s(PARROT_INTERP, const char *s, STRING
 **error_message)>
 
 =cut
@@ -1027,7 +1031,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 void *
-IMCC_compile_file_s(PARROT_INTERP, ARGIN(char *s),
+IMCC_compile_file_s(PARROT_INTERP, ARGIN(const char *s),
         ARGOUT(STRING **error_message))
 {
     ASSERT_ARGS(IMCC_compile_file_s)

Modified: trunk/include/parrot/imcc.h
==============================================================================
--- trunk/include/parrot/imcc.h	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/include/parrot/imcc.h	Wed Jun 10 18:36:20 2009	(r39498)
@@ -8,7 +8,7 @@
 
 PARROT_EXPORT void imcc_initialize(PARROT_INTERP);
 PARROT_EXPORT const char * parseflags(PARROT_INTERP, int *argc, char **argv[]);
-PARROT_EXPORT int imcc_run(PARROT_INTERP, char *sourcefile, int argc, char **argv);
+PARROT_EXPORT int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, char **argv);
 
 #endif /* PARROT_IMCC_H_GUARD */
 

Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/include/parrot/interpreter.h	Wed Jun 10 18:36:20 2009	(r39498)
@@ -601,7 +601,7 @@
 PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
 void * Parrot_compile_file(PARROT_INTERP,
-    ARGIN(char *fullname),
+    ARGIN(const char *fullname),
     ARGOUT(STRING **error))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)

Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/src/interp/inter_misc.c	Wed Jun 10 18:36:20 2009	(r39498)
@@ -154,7 +154,7 @@
 
 /*
 
-=item C<void * Parrot_compile_file(PARROT_INTERP, char *fullname, STRING
+=item C<void * Parrot_compile_file(PARROT_INTERP, const char *fullname, STRING
 **error)>
 
 Compile code file.
@@ -166,7 +166,7 @@
 PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
 void *
-Parrot_compile_file(PARROT_INTERP, ARGIN(char *fullname), ARGOUT(STRING **error))
+Parrot_compile_file(PARROT_INTERP, ARGIN(const char *fullname), ARGOUT(STRING **error))
 {
     ASSERT_ARGS(Parrot_compile_file)
     return IMCC_compile_file_s(interp, fullname, error);

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	Wed Jun 10 16:36:13 2009	(r39497)
+++ trunk/src/main.c	Wed Jun 10 18:36:20 2009	(r39498)
@@ -38,9 +38,9 @@
 int
 main(int argc, char * argv[])
 {
-    char    *sourcefile;
-    Interp  *interp;
-    int      status;
+    const char *sourcefile;
+    Interp     *interp;
+    int         status;
 
     /* internationalization setup */
     /* setlocale(LC_ALL, ""); */


More information about the parrot-commits mailing list