mirror of
https://github.com/tbamud/tbamud.git
synced 2025-12-23 18:50:13 +01:00
Bug Fix: Cured preceeding spaces in IBT notes
This commit is contained in:
parent
e557626162
commit
222be04ec5
4 changed files with 59 additions and 2 deletions
|
|
@ -45,6 +45,7 @@ Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist)
|
|||
Minor IBT change to list 'in-progress' IBT's in yellow
|
||||
Bug Fix: Webster added to the util makefile for make all (wasn't compiling)
|
||||
Update to webster code to hopefully fix 'tell m-w' bug
|
||||
IBT's no longer read preceding spaces (body and notes), which inserts spaces every copyover
|
||||
[Nov 01 2010] - Rumble
|
||||
Fixed do_scan crash due to exits to NOWHERE. (thanks Rhade)
|
||||
Changed do_score experience tnl to list only mortals since LVL_IMMORT showed negative EXP.
|
||||
|
|
|
|||
55
src/db.c
55
src/db.c
|
|
@ -2784,6 +2784,61 @@ char *fread_string(FILE *fl, const char *error)
|
|||
return (strlen(buf) ? strdup(buf) : NULL);
|
||||
}
|
||||
|
||||
/* fread_clean_string is the same as fread_string, but skips preceding spaces */
|
||||
char *fread_clean_string(FILE *fl, const char *error)
|
||||
{
|
||||
char buf[MAX_STRING_LENGTH], tmp[513];
|
||||
char *point, c;
|
||||
int done = 0, length = 0, templength;
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
do
|
||||
{
|
||||
if( feof( fl ) )
|
||||
{
|
||||
log( "%s", "fread_clean_string: EOF encountered on read." );
|
||||
return 0;
|
||||
}
|
||||
c = getc( fl );
|
||||
}
|
||||
while( isspace( c ) );
|
||||
ungetc( c, fl );
|
||||
|
||||
do {
|
||||
if (!fgets(tmp, 512, fl)) {
|
||||
log("SYSERR: fread_clean_string: format error at or near %s", error);
|
||||
exit(1);
|
||||
}
|
||||
/* If there is a '~', end the string; else put an "\r\n" over the '\n'. */
|
||||
/* now only removes trailing ~'s -- Welcor */
|
||||
point = strchr(tmp, '\0');
|
||||
for (point-- ; (*point=='\r' || *point=='\n'); point--);
|
||||
if (*point=='~') {
|
||||
*point='\0';
|
||||
done = 1;
|
||||
} else {
|
||||
*(++point) = '\r';
|
||||
*(++point) = '\n';
|
||||
*(++point) = '\0';
|
||||
}
|
||||
|
||||
templength = point - tmp;
|
||||
|
||||
if (length + templength >= MAX_STRING_LENGTH) {
|
||||
log("SYSERR: fread_clean_string: string too large (db.c)");
|
||||
log("%s", error);
|
||||
exit(1);
|
||||
} else {
|
||||
strcat(buf + length, tmp); /* strcat: OK (size checked above) */
|
||||
length += templength;
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
/* allocate space for the new string and copy it */
|
||||
return (strlen(buf) ? strdup(buf) : NULL);
|
||||
}
|
||||
|
||||
/* Read a numerical value from a given file */
|
||||
int fread_number(FILE *fp)
|
||||
{
|
||||
|
|
|
|||
1
src/db.h
1
src/db.h
|
|
@ -243,6 +243,7 @@ char *fread_action(FILE *fl, int nr);
|
|||
int create_entry(char *name);
|
||||
void zone_update(void);
|
||||
char *fread_string(FILE *fl, const char *error);
|
||||
char *fread_clean_string(FILE *fl, const char *error);
|
||||
int fread_number(FILE *fp);
|
||||
char *fread_line(FILE *fp);
|
||||
int fread_flags(FILE *fp, int *fg, int fg_size);
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ static IBT_DATA *read_ibt( char *filename, FILE *fp )
|
|||
{
|
||||
case 'B':
|
||||
if (!str_cmp(word, "Body")) STRFREE(ibtData->body);
|
||||
KEY("Body", ibtData->body, fread_string( fp, buf ));
|
||||
KEY("Body", ibtData->body, fread_clean_string( fp, buf ));
|
||||
break;
|
||||
|
||||
case 'E':
|
||||
|
|
@ -185,7 +185,7 @@ static IBT_DATA *read_ibt( char *filename, FILE *fp )
|
|||
if (!str_cmp(word, "Name") && ibtData->name) STRFREE(ibtData->name);
|
||||
if (!str_cmp(word, "Notes") && ibtData->notes) STRFREE(ibtData->notes);
|
||||
TXT_KEY("Name", ibtData->name, fread_line( fp ));
|
||||
KEY("Notes", ibtData->notes, fread_string( fp, buf ));
|
||||
KEY("Notes", ibtData->notes, fread_clean_string( fp, buf ));
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue