Skip to content

Commit 8a258fe

Browse files
committed
COMMON: update module error messages
1 parent e50faed commit 8a258fe

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/common/scan.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ int comp_check_labels() {
582582
}
583583

584584
/*
585-
* returns true if 'name' is a unit or c-module
585+
* returns 1 if 'name' is a unit, 2 if 'name' c-module otherwise 0
586586
*/
587587
int comp_check_lib(const char *name) {
588588
char tmp[SB_KEYWORD_SIZE + 1];
@@ -599,7 +599,7 @@ int comp_check_lib(const char *name) {
599599
char *lib_name = dir_sep ? dir_sep + 1 : lib->alias;
600600

601601
if (strcasecmp(lib_name, tmp) == 0) {
602-
return 1;
602+
return lib->type == 0 ? 2 : 1;
603603
}
604604
}
605605
}
@@ -678,15 +678,22 @@ bid_t comp_var_getID(const char *var_name) {
678678
//
679679
// If the name is not found in comp_libtable then it
680680
// is treated as a structure reference
681-
if (dot != NULL && comp_check_lib(tmp)) {
682-
for (i = 0; i < comp_varcount; i++) {
683-
if (strcasecmp(comp_vartable[i].name, tmp) == 0) {
684-
return i;
681+
if (dot != NULL) {
682+
int module_type = comp_check_lib(tmp);
683+
if (module_type) {
684+
for (i = 0; i < comp_varcount; i++) {
685+
if (strcasecmp(comp_vartable[i].name, tmp) == 0) {
686+
return i;
687+
}
688+
}
689+
if (module_type == 2) {
690+
*dot = '\0';
691+
sc_raise(MSG_MODULE_NO_MEMBER, tmp, dot + 1);
692+
} else {
693+
sc_raise(MSG_MEMBER_DOES_NOT_EXIST, tmp);
685694
}
695+
return 0;
686696
}
687-
688-
sc_raise(MSG_MEMBER_DOES_NOT_EXIST, tmp);
689-
return 0;
690697
}
691698
//
692699
// search in global name-space
@@ -4707,7 +4714,11 @@ int comp_pass1(const char *section, const char *text) {
47074714
comp_line = comp_udptable[i].pline;
47084715
char *dot = strchr(comp_udptable[i].name, '.');
47094716
if (dot) {
4710-
sc_raise(MSG_UNDEFINED_MAP, comp_udptable[i].name);
4717+
if (comp_check_lib(comp_udptable[i].name) == 2) {
4718+
sc_raise(MSG_MODULE_NO_RETURN, comp_udptable[i].name);
4719+
} else {
4720+
sc_raise(MSG_UNDEFINED_MAP, comp_udptable[i].name);
4721+
}
47114722
} else {
47124723
if (comp_is_func(comp_udptable[i].name) != -1) {
47134724
sc_raise(MSG_FUNC_NOT_ASSIGNED, comp_udptable[i].name);

src/languages/messages.en.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
#define MSG_MISSING_FOR "NEXT: Missing FOR on the same level"
8787
#define MSG_MISSING_IF "ENDIF: Missing IF on the same level"
8888
#define MSG_MEMBER_DOES_NOT_EXIST "Unit has no member named '%s'\n"
89+
#define MSG_MODULE_NO_MEMBER "Module '%s' has no member '%s'\n"
90+
#define MSG_MODULE_NO_RETURN "Module FUNC '%s' result not assigned\n"
8991
#define MSG_CANT_OPEN_FILE_AT "Can't open '%s' at '%s'\n"
9092
#define MSG_CANT_OPEN_FILE "Can't open '%s'\n"
9193
#define MSG_GRMODE_ERR "GRMODE, usage:<width>x<height>[x<bits-per-pixel>]\nExample: OPTION PREDEF GRMODE=640x480x4\n"

0 commit comments

Comments
 (0)