fix hex regex in SH
[nedit-bw.git] / Symbol-embed-name.patch
blobde5620ac58b56b986e047d7334b3e64c021eb843
1 ---
3 source/interpret.c | 39 +++++++++++++++++++++++++--------------
4 source/interpret.h | 4 ++--
5 2 files changed, 27 insertions(+), 16 deletions(-)
7 diff --quilt old/source/interpret.c new/source/interpret.c
8 --- old/source/interpret.c
9 +++ new/source/interpret.c
10 @@ -863,12 +863,12 @@ Symbol *LookupSymbol(const char *name)
12 Symbol *InstallSymbol(const char *name, enum symTypes type, DataValue value)
14 Symbol *s;
16 - s = (Symbol *)malloc(sizeof(Symbol));
17 - s->name = (char *)malloc(strlen(name)+1); /* +1 for '\0' */
18 + /* no +1, because of .name[1] */
19 + s = malloc(sizeof(Symbol) + strlen(name));
20 strcpy(s->name, name);
21 s->type = type;
22 s->value = value;
23 s->added = 0;
24 if (type == LOCAL_SYM) {
25 @@ -1224,15 +1224,14 @@ static void restoreContext(RestartData *
26 static void freeSymbolTable(Symbol *symTab)
28 Symbol *s;
30 while(symTab != NULL) {
31 - s = symTab;
32 - free(s->name);
33 - symTab = s->next;
34 - free((char *)s);
35 - }
36 + s = symTab;
37 + symTab = s->next;
38 + free(s);
39 + }
42 #define POP(dataVal) \
43 do { \
44 POP_CHECK(1); \
45 @@ -2529,11 +2528,11 @@ static int callSubroutineFromSymbol(Symb
46 ** values which are already there.
48 if (sym->type == MACRO_FUNCTION_SYM) {
49 PUSH_CHECK(3 + !haveNamedArgs);
51 - prog = (Program *)sym->value.val.str.rep;
52 + prog = sym->value.val.prog;
54 if (!haveNamedArgs)
55 *(StackP++) = noValue; /* push dummy named arg array */
57 StackP->tag = NO_TAG; /* return PC */
58 @@ -2719,18 +2718,30 @@ int OverlayRoutineFromSymbol(Symbol *sym
59 ** executed in the caller's context from a function in macro.c.
62 int OverlayRoutineFromProg(Program *prog, int nArgs, int removeArgs)
64 - Symbol sym;
65 + Symbol *sym;
66 + int ret;
68 + /* no +1, because of .name[1] */
69 + sym = malloc(sizeof(Symbol) + strlen(prog->name));
70 + if (NULL == sym) {
71 + return False;
72 + }
74 + sym->type = MACRO_FUNCTION_SYM;
75 + strcpy(sym->name, prog->name);
76 + sym->value.val.prog = prog;
77 + sym->next = NULL;
78 + sym->added = 0;
80 + ret = OverlayRoutineFromSymbol(sym, nArgs, removeArgs);
82 - sym.type = MACRO_FUNCTION_SYM;
83 - sym.name = prog->name;
84 - sym.value.val.str.rep = (char *)prog;
85 - sym.next = NULL;
86 + free(sym);
88 - return OverlayRoutineFromSymbol(&sym, nArgs, removeArgs);
89 + return ret;
93 ** For special call style where the $args array in the called function is
94 ** assigned from an array in the caller (as "calledFunc(=argsArray)"),
95 diff --quilt old/source/interpret.h new/source/interpret.h
96 --- old/source/interpret.h
97 +++ new/source/interpret.h
98 @@ -106,15 +106,15 @@ typedef struct SparseArrayEntryTag {
99 DataValue value;
100 } SparseArrayEntry;
102 /* symbol table entry */
103 typedef struct SymbolRec {
104 - char *name;
105 enum symTypes type;
106 DataValue value;
107 - struct SymbolRec *next; /* to link to another */
108 int added;
109 + struct SymbolRec *next; /* to link to another */
110 + char name[1];
111 } Symbol;
113 typedef struct ProgramTag {
114 Symbol *localSymList;
115 Inst *code;