(ship_ca): Fix selector name's ca_len.

(xflds): Ignore ca_len for NSC_STRINGY.
This commit is contained in:
Markus Armbruster 2004-08-30 16:20:05 +00:00
parent 8982ff2e18
commit 8db5a84a8f
2 changed files with 5 additions and 4 deletions

View file

@ -329,7 +329,7 @@ xdprval(struct valstr *val, char *sep)
static void static void
xdflds(struct castr ca[], void *ptr) xdflds(struct castr ca[], void *ptr)
{ {
int i, j; int i, j, n;
struct valstr val; struct valstr val;
char *sep = ""; char *sep = "";
@ -338,11 +338,12 @@ xdflds(struct castr ca[], void *ptr)
continue; continue;
if (ca[i].ca_flags & NSC_EXTRA) if (ca[i].ca_flags & NSC_EXTRA)
continue; continue;
n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0;
j = 0; j = 0;
do { do {
xdeval(&val, ca[i].ca_type, ptr, ca[i].ca_off, j); xdeval(&val, ca[i].ca_type, ptr, ca[i].ca_off, j);
sep = xdprval(&val, sep); sep = xdprval(&val, sep);
} while (++j < ca[i].ca_len); } while (++j < n);
} }
} }
@ -359,7 +360,7 @@ xdfldnam(struct castr ca[])
if (ca[i].ca_flags & NSC_EXTRA) if (ca[i].ca_flags & NSC_EXTRA)
continue; continue;
pr("%s%s", sep, ca[i].ca_name); pr("%s%s", sep, ca[i].ca_name);
if (ca[i].ca_len) if (ca[i].ca_len && ca[i].ca_type != NSC_STRINGY)
pr(" %d", ca[i].ca_len); pr(" %d", ca[i].ca_len);
sep = " "; sep = " ";
} }

View file

@ -143,7 +143,7 @@ struct castr ship_ca[] = {
{NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"}, {NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"},
{NSC_TIME, 0, 0, fldoff(shpstr, shp_timestamp), "timestamp"}, {NSC_TIME, 0, 0, fldoff(shpstr, shp_timestamp), "timestamp"},
/* FIXME sail stuff missing */ /* FIXME sail stuff missing */
{NSC_STRINGY, 0, 0, fldoff(shpstr, shp_name), "name"}, {NSC_STRINGY, 0, MAXSHPNAMLEN, fldoff(shpstr, shp_name), "name"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_fuel), "fuel"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_fuel), "fuel"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nchoppers), "nchoppers"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nchoppers), "nchoppers"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nxlight), "nxlight"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nxlight), "nxlight"},