projects
/
YACASL2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
comet2のプロンプトを(comet2 monitor)に変更
[YACASL2.git]
/
src
/
label.c
diff --git
a/src/label.c
b/src/label.c
index
2a39f41
..
9d34f77
100644
(file)
--- a/
src/label.c
+++ b/
src/label.c
@@
-1,10
+1,3
@@
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-#include "cerr.h"
-#include "cmem.h"
-#include "hash.h"
#include "assemble.h"
/**
#include "assemble.h"
/**
@@
-70,7
+63,7
@@
unsigned labelhash(const char *prog, const char *label)
int i = 0, j;
unsigned h;
int i = 0, j;
unsigned h;
- if(
*prog != '\0'
) {
+ if(
prog[0]
) {
keys[i++] = label_hashkey(prog);
}
keys[i] = label_hashkey(label);
keys[i++] = label_hashkey(prog);
}
keys[i] = label_hashkey(label);
@@
-101,7
+94,7
@@
WORD getlabel(const char *prog, const char *label)
for(p = labels[labelhash(prog, label)]; p != NULL; p = p->next) {
l = p->label;
for(p = labels[labelhash(prog, label)]; p != NULL; p = p->next) {
l = p->label;
- if((
*prog == '\0'
|| (strcmp(prog, l->prog) == 0)) &&
+ if((
!prog[0]
|| (strcmp(prog, l->prog) == 0)) &&
strcmp(label, l->label) == 0)
{
return l->adr;
strcmp(label, l->label) == 0)
{
return l->adr;
@@
-115,7
+108,7
@@
bool addlabel(const char *prog, const char *label, WORD adr)
assert(label != NULL);
LABELTAB *p;
LABELARRAY *l;
assert(label != NULL);
LABELTAB *p;
LABELARRAY *l;
- unsigned h
ashval
;
+ unsigned h;
/* 登録されたラベルを検索。すでに登録されている場合はエラー発生 */
if(getlabel(prog, label) != 0xFFFF) {
/* 登録されたラベルを検索。すでに登録されている場合はエラー発生 */
if(getlabel(prog, label) != 0xFFFF) {
@@
-134,9
+127,8
@@
bool addlabel(const char *prog, const char *label, WORD adr)
/* ラベル数を設定 */
labelcnt++;
/* ハッシュ表へ追加 */
/* ラベル数を設定 */
labelcnt++;
/* ハッシュ表へ追加 */
- hashval = labelhash(prog, label);
- p->next = labels[hashval];
- labels[hashval] = p;
+ p->next = labels[h = labelhash(prog, label)];
+ labels[h] = p;
return true;
}
return true;
}
@@
-155,7
+147,7
@@
void printlabel()
}
qsort(l, s, sizeof(*l), compare_adr);
for(i = 0; i < s; i++) {
}
qsort(l, s, sizeof(*l), compare_adr);
for(i = 0; i < s; i++) {
- if(
*(l[i]->prog) != '\0'
) {
+ if(
l[i]->prog[0]
) {
fprintf(stdout, "%s.", l[i]->prog);
}
fprintf(stdout, "%s ---> #%04X\n", l[i]->label, l[i]->adr);
fprintf(stdout, "%s.", l[i]->prog);
}
fprintf(stdout, "%s ---> #%04X\n", l[i]->label, l[i]->adr);
@@
-176,5
+168,6
@@
void freelabel()
FREE(p->label);
FREE(p);
}
FREE(p->label);
FREE(p);
}
+ labels[i] = NULL;
}
}
}
}