Numerous GIB bug fixes and optimizations. Fixed/updated some GIB scripts

as well.
This commit is contained in:
Brian Koropoff 2002-12-13 23:36:05 +00:00
parent 2a5ac8c42d
commit 32e5e6ef0b
5 changed files with 100 additions and 134 deletions

View file

@ -161,9 +161,9 @@ function custom::record::stop {
function custom::record { function custom::record {
custom.menu.cur = 0 custom.menu.cur = 0
custom.recording = "" custom.recording = ""
bind "0" "custom.record.stop" bind "0" "custom::record::stop"
bind "8" "custom.record.seek -1" bind "8" "custom::record::seek -1"
bind "9" "custom.record.seek 1" bind "9" "custom::record::seek 1"
for i in `range 1 7` { for i in `range 1 7` {
bind $i "custom::record::item ",($i-1) bind $i "custom::record::item ",($i-1)
} }

View file

@ -75,7 +75,7 @@ function zoom::increase {
ifnot ${zoom.zoomed} { ifnot ${zoom.zoomed} {
return return
} }
zoom.mult = (${zoom.mult.step}*${zoom.mult}) zoom.mult *= ${zoom.mult.step}
if (${zoom.mult} > ${zoom.mult.upper}) { if (${zoom.mult} > ${zoom.mult.upper}) {
zoom.mult = ${zoom.mult.upper} zoom.mult = ${zoom.mult.upper}
} }
@ -84,7 +84,7 @@ function zoom::increase {
function zoom::decrease { function zoom::decrease {
ifnot ${zoom.zoomed} return ifnot ${zoom.zoomed} return
zoom.mult = (${zoom.mult}/${zoom.mult.step}) zoom.mult /= ${zoom.mult.step}
if (${zoom.mult} < ${zoom.mult.lower}) { if (${zoom.mult} < ${zoom.mult.lower}) {
zoom.mult = ${zoom.mult.lower} zoom.mult = ${zoom.mult.lower}
} }

View file

@ -50,7 +50,7 @@ typedef struct gib_builtin_s {
#define GIB_USAGE(x) (Cbuf_Error ("syntax", "%s: invalid syntax\nusage: %s %s", GIB_Argv(0), GIB_Argv(0), (x))) #define GIB_USAGE(x) (Cbuf_Error ("syntax", "%s: invalid syntax\nusage: %s %s", GIB_Argv(0), GIB_Argv(0), (x)))
void GIB_Arg_Strip_Delim (unsigned int arg); void GIB_Arg_Strip_Delim (unsigned int arg);
void GIB_Return (const char *str); dstring_t *GIB_Return (const char *str);
void GIB_Builtin_Add (const char *name, void (*func) (void), enum gib_builtin_type_e type); void GIB_Builtin_Add (const char *name, void (*func) (void), enum gib_builtin_type_e type);
gib_builtin_t *GIB_Builtin_Find (const char *name); gib_builtin_t *GIB_Builtin_Find (const char *name);
void GIB_Builtin_Init (qboolean sandbox); void GIB_Builtin_Init (qboolean sandbox);

View file

@ -134,14 +134,18 @@ GIB_Arg_Strip_Delim (unsigned int arg)
} }
} }
void dstring_t *
GIB_Return (const char *str) GIB_Return (const char *str)
{ {
if (GIB_DATA(cbuf_active)->type != GIB_BUFFER_PROXY) if (GIB_DATA(cbuf_active)->type != GIB_BUFFER_PROXY)
return; return 0;
dstring_clearstr (GIB_DATA(cbuf_active->up)->ret.retval); dstring_clearstr (GIB_DATA(cbuf_active->up)->ret.retval);
dstring_appendstr (GIB_DATA(cbuf_active->up)->ret.retval, str);
GIB_DATA(cbuf_active->up)->ret.available = true; GIB_DATA(cbuf_active->up)->ret.available = true;
if (!str)
return GIB_DATA(cbuf_active->up)->ret.retval;
else
dstring_appendstr (GIB_DATA(cbuf_active->up)->ret.retval, str);
return 0;
} }
/* /*
@ -153,9 +157,7 @@ void
GIB_Function_f (void) GIB_Function_f (void)
{ {
if (GIB_Argc () != 3) if (GIB_Argc () != 3)
Cbuf_Error ("syntax", GIB_USAGE ("name program");
"function: invalid syntax\n"
"usage: function function_name {program}");
else else
GIB_Function_Define (GIB_Argv(1), GIB_Argv(2)); GIB_Function_Define (GIB_Argv(1), GIB_Argv(2));
} }
@ -164,9 +166,7 @@ void
GIB_Function_Get_f (void) GIB_Function_Get_f (void)
{ {
if (GIB_Argc () != 2) if (GIB_Argc () != 2)
Cbuf_Error ("syntax", GIB_USAGE ("name");
"function.get: invalid syntax\n"
"usage: function::get function_name");
else { else {
gib_function_t *f; gib_function_t *f;
if ((f = GIB_Function_Find (GIB_Argv (1)))) if ((f = GIB_Function_Find (GIB_Argv (1))))
@ -182,9 +182,7 @@ GIB_Local_f (void)
int i; int i;
if (GIB_Argc () < 2) if (GIB_Argc () < 2)
Cbuf_Error ("syntax", GIB_USAGE ("var1 [var2 var3 ...]");
"local: invalid syntax\n"
"usage: local varname1 varname2 varname3 [...]");
else else
for (i = 1; i < GIB_Argc(); i++) for (i = 1; i < GIB_Argc(); i++)
GIB_Var_Set_Local (cbuf_active, GIB_Argv(i), ""); GIB_Var_Set_Local (cbuf_active, GIB_Argv(i), "");
@ -196,9 +194,7 @@ GIB_Global_f (void)
int i; int i;
if (GIB_Argc () < 2) if (GIB_Argc () < 2)
Cbuf_Error ("syntax", GIB_USAGE ("var1 [var2 var3 ...]");
"global: invalid syntax\n"
"usage: global varname1 varname2 varname3 [...]");
else else
for (i = 1; i < GIB_Argc(); i++) for (i = 1; i < GIB_Argc(); i++)
GIB_Var_Set_Global (GIB_Argv(i), ""); GIB_Var_Set_Global (GIB_Argv(i), "");
@ -208,9 +204,8 @@ void
GIB_Global_Delete_f (void) GIB_Global_Delete_f (void)
{ {
if (GIB_Argc () != 2) if (GIB_Argc () != 2)
Cbuf_Error ("syntax", GIB_USAGE ("var");
"global::delete: invalid syntax\n" if (GIB_Var_Get_Global (GIB_Argv(1)))
"usage: global.delete variable");
GIB_Var_Free_Global (GIB_Argv(1)); GIB_Var_Free_Global (GIB_Argv(1));
} }
@ -220,9 +215,7 @@ GIB_Return_f (void)
cbuf_t *sp; cbuf_t *sp;
if (GIB_Argc () > 2) if (GIB_Argc () > 2)
Cbuf_Error ("syntax", GIB_USAGE ("[value]");
"return: invalid syntax\n"
"usage: return <value>");
else { else {
sp = cbuf_active; sp = cbuf_active;
while (sp->interpreter == &gib_interp && GIB_DATA(sp)->type == GIB_BUFFER_LOOP) { // Get out of loops while (sp->interpreter == &gib_interp && GIB_DATA(sp)->type == GIB_BUFFER_LOOP) { // Get out of loops
@ -241,7 +234,7 @@ GIB_Return_f (void)
!sp->up->up || // Nothing above proxy buffer on the stack !sp->up->up || // Nothing above proxy buffer on the stack
sp->up->up->interpreter != &gib_interp || // Not a GIB buffer to return to sp->up->up->interpreter != &gib_interp || // Not a GIB buffer to return to
!GIB_DATA(sp->up->up)->ret.waiting) // Buffer doesn't want a return value !GIB_DATA(sp->up->up)->ret.waiting) // Buffer doesn't want a return value
Sys_Printf("Warning: unwanted return value discarded.\n"); // Not a serious error Sys_Printf("GIB warning: unwanted return value discarded.\n"); // Not a serious error
else { else {
dstring_clearstr (GIB_DATA(sp->up->up)->ret.retval); dstring_clearstr (GIB_DATA(sp->up->up)->ret.retval);
dstring_appendstr (GIB_DATA(sp->up->up)->ret.retval, GIB_Argv(1)); dstring_appendstr (GIB_DATA(sp->up->up)->ret.retval, GIB_Argv(1));
@ -257,7 +250,7 @@ GIB_If_f (void)
if ((!strcmp (GIB_Argv (3), "else") && GIB_Argc() >= 5) || // if condition {program} else ... if ((!strcmp (GIB_Argv (3), "else") && GIB_Argc() >= 5) || // if condition {program} else ...
(GIB_Argc() == 3)) { // if condition {program} (GIB_Argc() == 3)) { // if condition {program}
condition = atoi(GIB_Argv(1)); condition = atoi(GIB_Argv(1));
if (!strcmp (GIB_Argv(0), "ifnot")) if (GIB_Argv(0)[2])
condition = !condition; condition = !condition;
if (condition) { if (condition) {
GIB_Arg_Strip_Delim (2); GIB_Arg_Strip_Delim (2);
@ -268,20 +261,14 @@ GIB_If_f (void)
} else if (GIB_Argc() > 5) } else if (GIB_Argc() > 5)
Cbuf_InsertText (cbuf_active, GIB_Args (4)); Cbuf_InsertText (cbuf_active, GIB_Args (4));
} else } else
Cbuf_Error ("syntax", GIB_USAGE ("condition program [else ...]");
"if: invalid syntax\n"
"usage: if condition {program} [else ...]"
);
} }
void void
GIB_While_f (void) GIB_While_f (void)
{ {
if (GIB_Argc() != 3) { if (GIB_Argc() != 3) {
Cbuf_Error ("syntax", GIB_USAGE ("condition program");
"while: invalid syntax\n"
"usage: while condition {program}"
);
} else { } else {
cbuf_t *sub = Cbuf_New (&gib_interp); cbuf_t *sub = Cbuf_New (&gib_interp);
GIB_DATA(sub)->type = GIB_BUFFER_LOOP; GIB_DATA(sub)->type = GIB_BUFFER_LOOP;
@ -292,7 +279,7 @@ GIB_While_f (void)
cbuf_active->down = sub; cbuf_active->down = sub;
sub->up = cbuf_active; sub->up = cbuf_active;
GIB_Arg_Strip_Delim (2); GIB_Arg_Strip_Delim (2);
dstring_appendstr (GIB_DATA(sub)->loop_program, va("ifnot %s break;%s", GIB_Argv (1), GIB_Argv (2))); dstring_appendstr (GIB_DATA(sub)->loop_program, va("ifnot %s break\n%s", GIB_Argv (1), GIB_Argv (2)));
Cbuf_AddText (sub, GIB_DATA(sub)->loop_program->str); Cbuf_AddText (sub, GIB_DATA(sub)->loop_program->str);
cbuf_active->state = CBUF_STATE_STACK; cbuf_active->state = CBUF_STATE_STACK;
} }
@ -305,10 +292,7 @@ GIB_Field_Get_f (void)
char *list, *end; char *list, *end;
const char *ifs; const char *ifs;
if (GIB_Argc() < 3 || GIB_Argc() > 4) { if (GIB_Argc() < 3 || GIB_Argc() > 4) {
Cbuf_Error ("syntax", GIB_USAGE ("list element [fs]");
"field::get: invalid syntax\n"
"usage: field::get list element [ifs]"
);
return; return;
} }
field = atoi (GIB_Argv(2)); field = atoi (GIB_Argv(2));
@ -377,12 +361,9 @@ GIB_For_f (void)
{ {
if (strcmp ("in", GIB_Argv (2)) || if (strcmp ("in", GIB_Argv (2)) ||
(GIB_Argc() == 7 && strcmp ("by", GIB_Argv(4))) || (GIB_Argc() == 7 && strcmp ("by", GIB_Argv(4))) ||
(GIB_Argc() != 5 && GIB_Argc() != 7)) { (GIB_Argc() != 5 && GIB_Argc() != 7))
Cbuf_Error ("syntax", GIB_USAGE ("variable in list [by fs] program");
"for: invalid syntax\n" else if (GIB_Argv (3)[0]) {
"usage: for variable in list {program}"
);
} else if (GIB_Argv (3)[0]) {
char *ll; char *ll;
const char *ifs; const char *ifs;
cbuf_t *sub = Cbuf_New (&gib_interp); cbuf_t *sub = Cbuf_New (&gib_interp);
@ -395,7 +376,7 @@ GIB_For_f (void)
Cbuf_DeleteStack (cbuf_active->down); Cbuf_DeleteStack (cbuf_active->down);
cbuf_active->down = sub; cbuf_active->down = sub;
sub->up = cbuf_active; sub->up = cbuf_active;
// Store all for-loop data in one big buffer (easy to clean up) // Store all for-loop data in one big dstring (easy to clean up)
dstring_appendstr (GIB_DATA(sub)->loop_data, GIB_Argv(3)); dstring_appendstr (GIB_DATA(sub)->loop_data, GIB_Argv(3));
dstring_append (GIB_DATA(sub)->loop_data, GIB_Argv(1), strlen(GIB_Argv(1))+1); dstring_append (GIB_DATA(sub)->loop_data, GIB_Argv(1), strlen(GIB_Argv(1))+1);
if (GIB_Argc() == 7) if (GIB_Argc() == 7)
@ -433,7 +414,7 @@ GIB_Continue_f (void)
{ {
if (GIB_DATA(cbuf_active)->type != GIB_BUFFER_LOOP) if (GIB_DATA(cbuf_active)->type != GIB_BUFFER_LOOP)
Cbuf_Error ("syntax", Cbuf_Error ("syntax",
"break attempted outside of a loop" "continue attempted outside of a loop"
); );
else else
dstring_clearstr (cbuf_active->buf); dstring_clearstr (cbuf_active->buf);
@ -465,9 +446,7 @@ GIB_Function_Export_f (void)
int i; int i;
if (GIB_Argc() < 2) if (GIB_Argc() < 2)
Cbuf_Error ("syntax", GIB_USAGE ("function1 [function2 function3 ...]");
"function::export: invalid syntax\n"
"usage: function::export function1 function2 function3 [...]");
for (i = 1; i < GIB_Argc(); i++) { for (i = 1; i < GIB_Argc(); i++) {
if (!(f = GIB_Function_Find (GIB_Argv (i)))) if (!(f = GIB_Function_Find (GIB_Argv (i))))
Cbuf_Error ("function", "function::export: function '%s' not found", GIB_Argv (i)); Cbuf_Error ("function", "function::export: function '%s' not found", GIB_Argv (i));
@ -481,37 +460,38 @@ GIB_Function_Export_f (void)
void void
GIB_String_Length_f (void) GIB_String_Length_f (void)
{ {
dstring_t *ret;
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", GIB_USAGE ("string");
"string::length: invalid syntax\n" else if ((ret = GIB_Return (0)))
"usage: string::length string"); dsprintf (ret, "%i", (int) strlen(GIB_Argv(1)));
else
GIB_Return (va("%i", (int) strlen(GIB_Argv(1))));
} }
void void
GIB_String_Equal_f (void) GIB_String_Equal_f (void)
{ {
if (GIB_Argc() != 3) if (GIB_Argc() != 3)
Cbuf_Error ("syntax", GIB_USAGE ("string1 string2");
"string::equal: invalid syntax\n" else if (strcmp(GIB_Argv(1), GIB_Argv(2)))
"usage: string::equal string1 string2"); GIB_Return ("0");
else else
GIB_Return (va("%i", !strcmp(GIB_Argv(1), GIB_Argv(2)))); GIB_Return ("1");
} }
void void
GIB_String_Findsub_f (void) GIB_String_Findsub_f (void)
{ {
dstring_t *ret;
char *haystack, *res; char *haystack, *res;
if (GIB_Argc() != 3) { if (GIB_Argc() != 3) {
GIB_USAGE ("string substr"); GIB_USAGE ("string substr");
return; return;
} }
haystack = GIB_Argv(1); haystack = GIB_Argv(1);
if ((res = strstr(haystack, GIB_Argv(2)))) if ((res = strstr(haystack, GIB_Argv(2)))) {
GIB_Return (va("%lu", (unsigned long int)(res - haystack))); if ((ret = GIB_Return (0)))
else dsprintf (ret, "%lu", (unsigned long int)(res - haystack));
} else
GIB_Return ("-1"); GIB_Return ("-1");
} }
@ -537,7 +517,7 @@ void
GIB_Regex_Replace_f (void) GIB_Regex_Replace_f (void)
{ {
regex_t *reg; regex_t *reg;
int ofs, len;//, e; int ofs, len;
regmatch_t match[10]; regmatch_t match[10];
if (GIB_Argc() != 5) { if (GIB_Argc() != 5) {
@ -563,6 +543,7 @@ GIB_Regex_Extract_f (void)
{ {
regex_t *reg; regex_t *reg;
regmatch_t *match; regmatch_t *match;
dstring_t *ret;
int i; int i;
char o; char o;
@ -583,7 +564,8 @@ GIB_Regex_Extract_f (void)
GIB_Argv(1)[match[i].rm_eo] = o; GIB_Argv(1)[match[i].rm_eo] = o;
} }
} }
GIB_Return (va("%lu", (unsigned long) match[0].rm_eo)); if ((ret = GIB_Return (0)))
dsprintf (ret, "%lu", (unsigned long) match[0].rm_eo);
} else } else
GIB_Return ("-1"); GIB_Return ("-1");
free (match); free (match);
@ -592,15 +574,15 @@ GIB_Regex_Extract_f (void)
void void
GIB_Thread_Create_f (void) GIB_Thread_Create_f (void)
{ {
dstring_t *ret;
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", GIB_USAGE ("program");
"thread::create: invalid syntax\n"
"usage: thread::create program");
else { else {
gib_thread_t *thread = GIB_Thread_New (); gib_thread_t *thread = GIB_Thread_New ();
Cbuf_AddText (thread->cbuf, GIB_Argv(1)); Cbuf_AddText (thread->cbuf, GIB_Argv(1));
GIB_Thread_Add (thread); GIB_Thread_Add (thread);
GIB_Return (va("%lu", thread->id)); if ((ret = GIB_Return (0)))
dsprintf (ret, "%lu", thread->id);
} }
} }
@ -608,9 +590,7 @@ void
GIB_Thread_Kill_f (void) GIB_Thread_Kill_f (void)
{ {
if (GIB_Argc() != 2) if (GIB_Argc() != 2)
Cbuf_Error ("syntax", GIB_USAGE ("id");
"thread::kill: invalid syntax\n"
"usage: thread::kill id");
else { else {
gib_thread_t *thread; gib_thread_t *thread;
cbuf_t *cur; cbuf_t *cur;
@ -640,7 +620,7 @@ GIB_File_Transform_Path_Null (dstring_t *path)
char *s; char *s;
// Convert backslash to forward slash // Convert backslash to forward slash
while ((s = strchr (path->str, '\\'))) for (s = strchr(path->str, '\\'); s; s = strchr (s, '\\'))
*s = '/'; *s = '/';
return 0; return 0;
} }
@ -650,7 +630,7 @@ GIB_File_Transform_Path_Secure (dstring_t *path)
{ {
char *s /* , e_dir[MAX_OSPATH] */; char *s /* , e_dir[MAX_OSPATH] */;
while ((s = strchr (path->str, '\\'))) for (s = strchr(path->str, '\\'); s; s = strchr (s, '\\'))
*s = '/'; *s = '/';
if (Sys_PathType (path->str) != PATHTYPE_RELATIVE_BELOW) if (Sys_PathType (path->str) != PATHTYPE_RELATIVE_BELOW)
return -1; return -1;
@ -664,13 +644,12 @@ void
GIB_File_Read_f (void) GIB_File_Read_f (void)
{ {
QFile *file; QFile *file;
char *path, *contents = 0; char *path;
int len; int len;
dstring_t *ret;
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", GIB_USAGE ("file");
"file::read: invalid syntax\n"
"usage: file::read path_and_filename");
return; return;
} }
if (!*GIB_Argv (1)) { if (!*GIB_Argv (1)) {
@ -683,23 +662,23 @@ GIB_File_Read_f (void)
"file::read: access to %s denied", GIB_Argv(1)); "file::read: access to %s denied", GIB_Argv(1));
return; return;
} }
if (!(ret = GIB_Return (0)))
return;
path = GIB_Argv (1); path = GIB_Argv (1);
file = Qopen (path, "r"); file = Qopen (path, "r");
if (file) { if (file) {
len = Qfilesize (file); len = Qfilesize (file);
contents = (char *) malloc (len + 1); ret->size = len+1;
SYS_CHECKMEM (contents); dstring_adjust (ret);
contents[len] = 0; Qread (file, ret->str, len);
Qread (file, contents, len); ret->str[len] = 0;
Qclose (file); Qclose (file);
} }
if (!contents) { if (!file) {
Cbuf_Error ("file", Cbuf_Error ("file",
"file::read: could not open %s for reading: %s", path, strerror (errno)); "file::read: could not read %s: %s", path, strerror (errno));
return; return;
} }
GIB_Return (contents);
free (contents);
} }
void void
@ -709,9 +688,7 @@ GIB_File_Write_f (void)
char *path; char *path;
if (GIB_Argc () != 3) { if (GIB_Argc () != 3) {
Cbuf_Error ("syntax", GIB_USAGE ("file data");
"file::write: invalid syntax\n"
"usage: file::write path_and_filename data");
return; return;
} }
if (!*GIB_Argv(1)) { if (!*GIB_Argv(1)) {
@ -744,9 +721,7 @@ GIB_File_Find_f (void)
dstring_t *list; dstring_t *list;
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", GIB_USAGE ("glob");
"file::find: invalid syntax\n"
"usage: file::find path_and_glob");
return; return;
} }
if (GIB_File_Transform_Path (GIB_Argd(1))) { if (GIB_File_Transform_Path (GIB_Argd(1))) {
@ -759,11 +734,11 @@ GIB_File_Find_f (void)
if (!s) { // No slash in path if (!s) { // No slash in path
glob = path; // The glob is the entire argument glob = path; // The glob is the entire argument
path = "."; // The path is the current directory path = "."; // The path is the current directory
} else { } else if (s == path) // Unix filesystem root (carne only)
path = "/";
else {
*s = 0; // Split the string at the final slash *s = 0; // Split the string at the final slash
glob = s+1; glob = s+1;
if (!*path) // If we now have a null path...
path = "/"; // we wanted the filesystem root in unix
} }
directory = opendir (path); directory = opendir (path);
if (!directory) { if (!directory) {
@ -771,7 +746,7 @@ GIB_File_Find_f (void)
"file.find: could not open directory %s: %s", path, strerror (errno)); "file.find: could not open directory %s: %s", path, strerror (errno));
return; return;
} }
list = dstring_newstr (); if ((list = GIB_Return (0))) {
if (!(ifs = GIB_Var_Get_Local (cbuf_active, "ifs"))) if (!(ifs = GIB_Var_Get_Local (cbuf_active, "ifs")))
ifs = "\n"; // Newlines don't appear in filenames and are part of the default ifs ifs = "\n"; // Newlines don't appear in filenames and are part of the default ifs
while ((entry = readdir (directory))) { while ((entry = readdir (directory))) {
@ -782,11 +757,8 @@ GIB_File_Find_f (void)
dstring_appendstr (list, entry->d_name); dstring_appendstr (list, entry->d_name);
} }
} }
if (list->str[0]) }
GIB_Return (list->str + 1); closedir (directory);
else
GIB_Return ("");
dstring_delete (list);
} }
void void
@ -795,9 +767,7 @@ GIB_File_Move_f (void)
char *path1, *path2; char *path1, *path2;
if (GIB_Argc () != 3) { if (GIB_Argc () != 3) {
Cbuf_Error ("syntax", GIB_USAGE ("from_file to_file");
"file::move: invalid syntax\n"
"usage: file::move from_file to_file");
return; return;
} }
if (GIB_File_Transform_Path (GIB_Argd(1))) { if (GIB_File_Transform_Path (GIB_Argd(1))) {
@ -824,9 +794,7 @@ GIB_File_Delete_f (void)
char *path; char *path;
if (GIB_Argc () != 2) { if (GIB_Argc () != 2) {
Cbuf_Error ("syntax", GIB_USAGE ("file");
"file::delete: invalid syntax\n"
"usage: file::delete file");
return; return;
} }
if (GIB_File_Transform_Path (GIB_Argd(1))) { if (GIB_File_Transform_Path (GIB_Argd(1))) {
@ -848,9 +816,7 @@ GIB_Range_f (void)
dstring_t *dstr; dstring_t *dstr;
const char *ifs; const char *ifs;
if (GIB_Argc () < 3 || GIB_Argc () > 4) { if (GIB_Argc () < 3 || GIB_Argc () > 4) {
Cbuf_Error ("syntax", GIB_USAGE ("lower upper [step]");
"range: invalid syntax\n"
"range: lower upper [step]");
return; return;
} }
@ -877,9 +843,7 @@ void
GIB_Print_f (void) GIB_Print_f (void)
{ {
if (GIB_Argc() != 2) { if (GIB_Argc() != 2) {
Cbuf_Error ("syntax", GIB_USAGE ("text");
"print: invalid syntax\n"
"usage: print text");
return; return;
} }
Sys_Printf ("%s", GIB_Argv(1)); Sys_Printf ("%s", GIB_Argv(1));

View file

@ -278,8 +278,10 @@ GIB_Parse_Extract_Line (struct cbuf_s *cbuf)
if (dstr->str[0]) { // If something is left in the buffer if (dstr->str[0]) { // If something is left in the buffer
if (i)// If we used any of it if (i)// If we used any of it
dstring_insert (cbuf->line, 0, dstr->str, i); dstring_insert (cbuf->line, 0, dstr->str, i);
// Clip out what we used or any leftover newlines or ;s // Clip out what we used
dstring_snip (dstr, 0, i + (dstr->str[i] == '\n' || dstr->str[i] == ';')); while (isspace ((byte) dstr->str[i]) || dstr->str[i] == ';') // Eliminate white space/null statements
i++;
dstring_snip (dstr, 0, i);
} }
return; return;