[svn:parrot] r39493 - in trunk: compilers/imcc include/parrot src src/interp
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed Jun 10 15:05:20 UTC 2009
Author: NotFound
Date: Wed Jun 10 15:05:18 2009
New Revision: 39493
URL: https://trac.parrot.org/parrot/changeset/39493
Log:
[cage] fix some constness problems and potential allocation errors with filenames passed to imcc
Modified:
trunk/compilers/imcc/imc.h
trunk/compilers/imcc/imcc.l
trunk/compilers/imcc/imclexer.c
trunk/compilers/imcc/main.c
trunk/compilers/imcc/parser_util.c
trunk/include/parrot/imcc.h
trunk/include/parrot/interpreter.h
trunk/src/embed.c
trunk/src/interp/inter_misc.c
trunk/src/main.c
trunk/src/parrot_debugger.c
Modified: trunk/compilers/imcc/imc.h
==============================================================================
--- trunk/compilers/imcc/imc.h Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/compilers/imcc/imc.h Wed Jun 10 15:05:18 2009 (r39493)
@@ -236,13 +236,13 @@
FUNC_MODIFIES(*error_message);
PARROT_CANNOT_RETURN_NULL
-void * IMCC_compile_file(PARROT_INTERP, ARGIN(const char *s))
+void * IMCC_compile_file(PARROT_INTERP, ARGIN(char *s))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_CANNOT_RETURN_NULL
void * IMCC_compile_file_s(PARROT_INTERP,
- ARGIN(const char *s),
+ ARGIN(char *s),
ARGOUT(STRING **error_message))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
@@ -525,7 +525,7 @@
struct parser_state_t {
struct parser_state_t *next;
Interp *interp;
- const char *file;
+ char *file;
FILE *handle;
int file_needs_free; /* is *file malloced? */
int line;
Modified: trunk/compilers/imcc/imcc.l
==============================================================================
--- trunk/compilers/imcc/imcc.l Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/compilers/imcc/imcc.l Wed Jun 10 15:05:18 2009 (r39493)
@@ -1154,8 +1154,8 @@
if (m) {
int i,c,start_cond;
- macro_frame_t * const frame = new_frame(interp);
- frame->params = &m->params;
+ macro_frame_t * frame = new_frame(interp);
+ frame->params = &m->params;
/* When an error occurs, then report it as being in a macro */
frame->is_macro = 1;
Modified: trunk/compilers/imcc/imclexer.c
==============================================================================
--- trunk/compilers/imcc/imclexer.c Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/compilers/imcc/imclexer.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -5567,8 +5567,8 @@
if (m) {
int i,c,start_cond;
- macro_frame_t * const frame = new_frame(interp);
- frame->params = &m->params;
+ macro_frame_t * frame = new_frame(interp);
+ frame->params = &m->params;
/* When an error occurs, then report it as being in a macro */
frame->is_macro = 1;
Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/compilers/imcc/main.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -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(const char * const sourcefile),
+ ARGIN(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, const char * const
-sourcefile, const char * const output_file)>
+=item C<static void compile_to_bytecode(PARROT_INTERP, 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(const char * const sourcefile),
+ ARGIN(char * const sourcefile),
ARGIN_NULLOK(const char * const output_file))
{
ASSERT_ARGS(compile_to_bytecode)
@@ -1003,8 +1003,7 @@
/*
-=item C<int imcc_run(PARROT_INTERP, const char *sourcefile, int argc, char
-**argv)>
+=item C<int imcc_run(PARROT_INTERP, 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)
@@ -1015,7 +1014,7 @@
*/
int
-imcc_run(PARROT_INTERP, ARGIN(const char *sourcefile), int argc,
+imcc_run(PARROT_INTERP, ARGIN(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 07:28:01 2009 (r39492)
+++ trunk/compilers/imcc/parser_util.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -59,7 +59,7 @@
PARROT_CANNOT_RETURN_NULL
static void * imcc_compile_file(PARROT_INTERP,
- ARGIN(const char *fullname),
+ ARGIN(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, const char *fullname,
-STRING **error_message)>
+=item C<static void * imcc_compile_file(PARROT_INTERP, 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(const char *fullname),
+imcc_compile_file(PARROT_INTERP, ARGIN(char *fullname),
ARGOUT(STRING **error_message))
{
ASSERT_ARGS(imcc_compile_file)
@@ -998,7 +998,7 @@
/*
-=item C<void * IMCC_compile_file(PARROT_INTERP, const char *s)>
+=item C<void * IMCC_compile_file(PARROT_INTERP, char *s)>
Note: This function is provided for backward compatibility. This
function can go away in future.
@@ -1009,7 +1009,7 @@
PARROT_CANNOT_RETURN_NULL
void *
-IMCC_compile_file(PARROT_INTERP, ARGIN(const char *s))
+IMCC_compile_file(PARROT_INTERP, ARGIN(char *s))
{
ASSERT_ARGS(IMCC_compile_file)
STRING *error_message;
@@ -1018,7 +1018,7 @@
/*
-=item C<void * IMCC_compile_file_s(PARROT_INTERP, const char *s, STRING
+=item C<void * IMCC_compile_file_s(PARROT_INTERP, char *s, STRING
**error_message)>
=cut
@@ -1027,7 +1027,7 @@
PARROT_CANNOT_RETURN_NULL
void *
-IMCC_compile_file_s(PARROT_INTERP, ARGIN(const char *s),
+IMCC_compile_file_s(PARROT_INTERP, ARGIN(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 07:28:01 2009 (r39492)
+++ trunk/include/parrot/imcc.h Wed Jun 10 15:05:18 2009 (r39493)
@@ -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, const char *sourcefile, int argc, char **argv);
+PARROT_EXPORT int imcc_run(PARROT_INTERP, 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 07:28:01 2009 (r39492)
+++ trunk/include/parrot/interpreter.h Wed Jun 10 15:05:18 2009 (r39493)
@@ -601,7 +601,7 @@
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
void * Parrot_compile_file(PARROT_INTERP,
- ARGIN(const char *fullname),
+ ARGIN(char *fullname),
ARGOUT(STRING **error))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/src/embed.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -737,7 +737,7 @@
{
ASSERT_ARGS(calibrate)
opcode_t code[] = { 1 }; /* noop */
- const opcode_t *pc = code;
+ opcode_t *pc = code;
const size_t count = 1000000;
size_t n = count;
const FLOATVAL start = Parrot_floatval_time();
Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/src/interp/inter_misc.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -154,7 +154,7 @@
/*
-=item C<void * Parrot_compile_file(PARROT_INTERP, const char *fullname, STRING
+=item C<void * Parrot_compile_file(PARROT_INTERP, char *fullname, STRING
**error)>
Compile code file.
@@ -166,7 +166,7 @@
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
void *
-Parrot_compile_file(PARROT_INTERP, ARGIN(const char *fullname), ARGOUT(STRING **error))
+Parrot_compile_file(PARROT_INTERP, ARGIN(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 07:28:01 2009 (r39492)
+++ trunk/src/main.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -38,7 +38,7 @@
int
main(int argc, char * argv[])
{
- const char *sourcefile;
+ char *sourcefile;
Interp *interp;
int status;
@@ -57,7 +57,7 @@
available. */
Parrot_set_executable_name(interp, Parrot_str_new(interp, argv[0], 0));
- sourcefile = parseflags(interp, &argc, &argv);
+ sourcefile = strdup(parseflags(interp, &argc, &argv));
status = imcc_run(interp, sourcefile, argc, argv);
UNUSED(status);
Modified: trunk/src/parrot_debugger.c
==============================================================================
--- trunk/src/parrot_debugger.c Wed Jun 10 07:28:01 2009 (r39492)
+++ trunk/src/parrot_debugger.c Wed Jun 10 15:05:18 2009 (r39493)
@@ -108,6 +108,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <ctype.h>
#include "../compilers/imcc/imc.h"
#include "../compilers/imcc/parser.h"
@@ -183,7 +184,7 @@
Parrot_pbc_load(interp, pf);
IMCC_push_parser_state(interp);
- IMCC_INFO(interp)->state->file = filename;
+ IMCC_INFO(interp)->state->file = strdup(filename);
if (!(imc_yyin_set(fopen(filename, "r"), yyscanner))) {
IMCC_fatal_standalone(interp, EXCEPTION_PIO_ERROR,
More information about the parrot-commits
mailing list