CVS rebase
[nedit-bw.git] / Symbol-embed-name.patch
blob882fc1a3c38ae8fa0a0e096f38551c6d7a15103a
1 ---
3 source/interpret.c | 37 ++++++++++++++++++++++++-------------
4 source/interpret.h | 4 ++--
5 2 files changed, 26 insertions(+), 15 deletions(-)
7 diff --quilt old/source/interpret.c new/source/interpret.c
8 --- old/source/interpret.c
9 +++ new/source/interpret.c
10 @@ -862,8 +862,8 @@ Symbol *InstallSymbol(const char *name,
12 Symbol *s;
14 - s = (Symbol *)malloc(sizeof(Symbol));
15 - s->name = (char *)malloc(strlen(name)+1); /* +1 for '\0' */
16 + /* no +1, because of .name[1] */
17 + s = malloc(sizeof(Symbol) + strlen(name));
18 strcpy(s->name, name);
19 s->type = type;
20 s->value = value;
21 @@ -1254,11 +1254,10 @@ static void freeSymbolTable(Symbol *symT
22 Symbol *s;
24 while(symTab != NULL) {
25 - s = symTab;
26 - free(s->name);
27 - symTab = s->next;
28 - free((char *)s);
29 - }
30 + s = symTab;
31 + symTab = s->next;
32 + free(s);
33 + }
36 #define POP(dataVal) \
37 @@ -2751,14 +2750,26 @@ int OverlayRoutineFromSymbol(Symbol *sym
39 int OverlayRoutineFromProg(Program *prog, int nArgs, int removeArgs)
41 - Symbol sym;
42 + Symbol *sym;
43 + int ret;
45 + /* no +1, because of .name[1] */
46 + sym = malloc(sizeof(Symbol) + strlen(prog->name));
47 + if (NULL == sym) {
48 + return False;
49 + }
51 + sym->type = MACRO_FUNCTION_SYM;
52 + strcpy(sym->name, prog->name);
53 + sym->value.val.prog = prog;
54 + sym->next = NULL;
55 + sym->added = 0;
57 + ret = OverlayRoutineFromSymbol(sym, nArgs, removeArgs);
59 - sym.type = MACRO_FUNCTION_SYM;
60 - sym.name = prog->name;
61 - sym.value.val.str.rep = (char *)prog;
62 - sym.next = NULL;
63 + free(sym);
65 - return OverlayRoutineFromSymbol(&sym, nArgs, removeArgs);
66 + return ret;
70 diff --quilt old/source/interpret.h new/source/interpret.h
71 --- old/source/interpret.h
72 +++ new/source/interpret.h
73 @@ -108,11 +108,11 @@ typedef struct SparseArrayEntryTag {
75 /* symbol table entry */
76 typedef struct SymbolRec {
77 - char *name;
78 enum symTypes type;
79 DataValue value;
80 - struct SymbolRec *next; /* to link to another */
81 int added;
82 + struct SymbolRec *next; /* to link to another */
83 + char name[1];
84 } Symbol;
86 typedef struct ProgramTag {