Commit 4c367511 authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

plug-ins/script-fu/siod/siod.h Reverted changes to handling of string

2005-12-16  Kevin Cozens  <kcozens@cvs.gnome.org>

	* plug-ins/script-fu/siod/siod.h
	* plug-ins/script-fu/siod/sliba.c: Reverted changes to handling
	of string arrays to stay backward compatible (see bug #168290 and
	bug #317634). These files were not reverted when other files were.
parent 17d835fb
2005-12-16 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/siod/siod.h
* plug-ins/script-fu/siod/sliba.c: Reverted changes to handling
of string arrays to stay backward compatible (see bug #168290 and
bug #317634). These files were not reverted when other files were.
2005-12-16 Michael Natterer <mitch@gimp.org> 2005-12-16 Michael Natterer <mitch@gimp.org>
* plug-ins/common/screenshot.c (shoot_dialog): cleaned up the GUI. * plug-ins/common/screenshot.c (shoot_dialog): cleaned up the GUI.
......
...@@ -110,12 +110,6 @@ struct obj ...@@ -110,12 +110,6 @@ struct obj
char *data; char *data;
} }
string; string;
struct
{
long dim;
char **data;
}
string_array;
struct struct
{ {
long dim; long dim;
...@@ -145,7 +139,6 @@ struct obj ...@@ -145,7 +139,6 @@ struct obj
#define SUBRM(x) (*((*x).storage_as.subrm.f)) #define SUBRM(x) (*((*x).storage_as.subrm.f))
#define SUBRF(x) (*((*x).storage_as.subr.f)) #define SUBRF(x) (*((*x).storage_as.subr.f))
#define FLONM(x) ((*x).storage_as.flonum.data) #define FLONM(x) ((*x).storage_as.flonum.data)
#define STRING(x) ((*x).storage_as.string.data)
#define NIL ((struct obj *) 0) #define NIL ((struct obj *) 0)
#define EQ(x,y) ((x) == (y)) #define EQ(x,y) ((x) == (y))
...@@ -180,7 +173,6 @@ struct obj ...@@ -180,7 +173,6 @@ struct obj
#define tc_subr_4 19 #define tc_subr_4 19
#define tc_subr_5 20 #define tc_subr_5 20
#define tc_subr_2n 21 #define tc_subr_2n 21
#define tc_string_array 22
#define FO_comment 35 #define FO_comment 35
#define tc_user_min 50 #define tc_user_min 50
#define tc_user_max 100 #define tc_user_max 100
...@@ -198,14 +190,10 @@ typedef LISP (*SUBR_FUNC) (void); ...@@ -198,14 +190,10 @@ typedef LISP (*SUBR_FUNC) (void);
#define CONSP(x) TYPEP(x,tc_cons) #define CONSP(x) TYPEP(x,tc_cons)
#define FLONUMP(x) TYPEP(x,tc_flonum) #define FLONUMP(x) TYPEP(x,tc_flonum)
#define SYMBOLP(x) TYPEP(x,tc_symbol) #define SYMBOLP(x) TYPEP(x,tc_symbol)
#define STRINGP(x) TYPEP(x,tc_string)
#define STRARYP(x) TYPEP(x,tc_string_array)
#define NCONSP(x) NTYPEP(x,tc_cons) #define NCONSP(x) NTYPEP(x,tc_cons)
#define NFLONUMP(x) NTYPEP(x,tc_flonum) #define NFLONUMP(x) NTYPEP(x,tc_flonum)
#define NSYMBOLP(x) NTYPEP(x,tc_symbol) #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
#define NSTRINGP(x) NTYPEP(x,tc_string)
#define NSTRARYP(x) NTYPEP(x,tc_string_array)
#define TKBUFFERN 5120 #define TKBUFFERN 5120
......
...@@ -59,7 +59,6 @@ init_storage_a (void) ...@@ -59,7 +59,6 @@ init_storage_a (void)
gc_protect (&bashnum); gc_protect (&bashnum);
bashnum = newcell (tc_flonum); bashnum = newcell (tc_flonum);
init_storage_a1 (tc_string); init_storage_a1 (tc_string);
init_storage_a1 (tc_string_array);
init_storage_a1 (tc_double_array); init_storage_a1 (tc_double_array);
init_storage_a1 (tc_long_array); init_storage_a1 (tc_long_array);
init_storage_a1 (tc_lisp_array); init_storage_a1 (tc_lisp_array);
...@@ -102,7 +101,6 @@ array_gc_mark (LISP ptr) ...@@ -102,7 +101,6 @@ array_gc_mark (LISP ptr)
void void
array_gc_free (LISP ptr) array_gc_free (LISP ptr)
{ {
int i;
switch (ptr->type) switch (ptr->type)
{ {
case tc_string: case tc_string:
...@@ -115,11 +113,6 @@ array_gc_free (LISP ptr) ...@@ -115,11 +113,6 @@ array_gc_free (LISP ptr)
case tc_long_array: case tc_long_array:
free (ptr->storage_as.long_array.data); free (ptr->storage_as.long_array.data);
break; break;
case tc_string_array:
for (i = 0; i < ptr->storage_as.string_array.dim; ++i)
free (ptr->storage_as.string_array.data[i]);
free (ptr->storage_as.string_array.data);
break;
case tc_lisp_array: case tc_lisp_array:
free (ptr->storage_as.lisp_array.data); free (ptr->storage_as.lisp_array.data);
break; break;
...@@ -127,58 +120,48 @@ array_gc_free (LISP ptr) ...@@ -127,58 +120,48 @@ array_gc_free (LISP ptr)
} }
void void
array_prin1_string (char *ptr, struct gen_printio *f) array_prin1 (LISP ptr, struct gen_printio *f)
{ {
int i; int i, j;
switch (ptr->type)
gput_st (f, "\"");
if (ptr != NULL)
{ {
if (strcspn (ptr, "\"\\\n\r\t") == strlen (ptr)) case tc_string:
gput_st (f, ptr); gput_st (f, "\"");
if (strcspn (ptr->storage_as.string.data, "\"\\\n\r\t") ==
strlen (ptr->storage_as.string.data))
gput_st (f, ptr->storage_as.string.data);
else else
{ {
int n, c; int n, c;
char cbuff[3]; char cbuff[3];
n = strlen (ptr); n = strlen (ptr->storage_as.string.data);
for (i = 0; i < n; ++i) for (j = 0; j < n; ++j)
switch (c = ptr[i]) switch (c = ptr->storage_as.string.data[j])
{ {
case '\\': case '\\':
case '"': case '"':
cbuff[0] = '\\'; cbuff[0] = '\\';
cbuff[1] = c; cbuff[1] = c;
cbuff[2] = 0; cbuff[2] = 0;
gput_st (f, cbuff); gput_st (f, cbuff);
break; break;
case '\n': case '\n':
gput_st (f, "\\n"); gput_st (f, "\\n");
break; break;
case '\r': case '\r':
gput_st (f, "\\r"); gput_st (f, "\\r");
break; break;
case '\t': case '\t':
gput_st (f, "\\t"); gput_st (f, "\\t");
break; break;
default: default:
cbuff[0] = c; cbuff[0] = c;
cbuff[1] = 0; cbuff[1] = 0;
gput_st (f, cbuff); gput_st (f, cbuff);
break; break;
} }
} }
} gput_st (f, "\"");
gput_st (f, "\"");
}
void
array_prin1 (LISP ptr, struct gen_printio *f)
{
int i, j;
switch (ptr->type)
{
case tc_string:
array_prin1_string (ptr->storage_as.string.data, f);
break; break;
case tc_double_array: case tc_double_array:
gput_st (f, "#("); gput_st (f, "#(");
...@@ -220,16 +203,6 @@ array_prin1 (LISP ptr, struct gen_printio *f) ...@@ -220,16 +203,6 @@ array_prin1 (LISP ptr, struct gen_printio *f)
gput_st (f, tkbuffer); gput_st (f, tkbuffer);
gput_st (f, "\""); gput_st (f, "\"");
break; break;
case tc_string_array:
gput_st (f, "#(");
for (j = 0; j < ptr->storage_as.string_array.dim; ++j)
{
array_prin1_string (ptr->storage_as.string_array.data[j], f);
if ((j + 1) < ptr->storage_as.string_array.dim)
gput_st (f, " ");
}
gput_st (f, ")");
break;
case tc_lisp_array: case tc_lisp_array:
gput_st (f, "#("); gput_st (f, "#(");
for (j = 0; j < ptr->storage_as.lisp_array.dim; ++j) for (j = 0; j < ptr->storage_as.lisp_array.dim; ++j)
...@@ -342,6 +315,7 @@ aref1 (LISP a, LISP i) ...@@ -342,6 +315,7 @@ aref1 (LISP a, LISP i)
switch TYPE switch TYPE
(a) (a)
{ {
case tc_string:
case tc_byte_array: case tc_byte_array:
if (k >= a->storage_as.string.dim) if (k >= a->storage_as.string.dim)
my_err ("index too large", i); my_err ("index too large", i);
...@@ -354,10 +328,6 @@ aref1 (LISP a, LISP i) ...@@ -354,10 +328,6 @@ aref1 (LISP a, LISP i)
if (k >= a->storage_as.long_array.dim) if (k >= a->storage_as.long_array.dim)
my_err ("index too large", i); my_err ("index too large", i);
return (flocons (a->storage_as.long_array.data[k])); return (flocons (a->storage_as.long_array.data[k]));
case tc_string_array:
if (k >= a->storage_as.string_array.dim)
my_err ("index too large", i);
return (strcons (-1, a->storage_as.string_array.data[k]));
case tc_lisp_array: case tc_lisp_array:
if (k >= a->storage_as.lisp_array.dim) if (k >= a->storage_as.lisp_array.dim)
my_err ("index too large", i); my_err ("index too large", i);
...@@ -391,6 +361,7 @@ aset1 (LISP a, LISP i, LISP v) ...@@ -391,6 +361,7 @@ aset1 (LISP a, LISP i, LISP v)
switch TYPE switch TYPE
(a) (a)
{ {
case tc_string:
case tc_byte_array: case tc_byte_array:
if NFLONUMP if NFLONUMP
(v) err2_aset1 (v); (v) err2_aset1 (v);
...@@ -412,15 +383,6 @@ aset1 (LISP a, LISP i, LISP v) ...@@ -412,15 +383,6 @@ aset1 (LISP a, LISP i, LISP v)
err1_aset1 (i); err1_aset1 (i);
a->storage_as.long_array.data[k] = (long) FLONM (v); a->storage_as.long_array.data[k] = (long) FLONM (v);
return (v); return (v);
case tc_string_array:
if NSTRINGP
(v) err2_aset1 (v);
if (k >= a->storage_as.string_array.dim)
err1_aset1 (i);
if (a->storage_as.string_array.data[k] != NULL)
free (a->storage_as.string_array.data[k]);
a->storage_as.string_array.data[k] = strdup (STRING (v));
return (v);
case tc_lisp_array: case tc_lisp_array:
if (k >= a->storage_as.lisp_array.dim) if (k >= a->storage_as.lisp_array.dim)
err1_aset1 (i); err1_aset1 (i);
...@@ -455,14 +417,6 @@ arcons (long typecode, long n, long initp) ...@@ -455,14 +417,6 @@ arcons (long typecode, long n, long initp)
for (j = 0; j < n; ++j) for (j = 0; j < n; ++j)
a->storage_as.long_array.data[j] = 0; a->storage_as.long_array.data[j] = 0;
break; break;
case tc_string_array:
a->storage_as.string_array.dim = n;
a->storage_as.string_array.data = (char **) must_malloc (n *
sizeof (char *));
if (initp)
for (j = 0; j < n; ++j)
a->storage_as.string_array.data[j] = 0;
break;
case tc_string: case tc_string:
a->storage_as.string.dim = n; a->storage_as.string.dim = n;
a->storage_as.string.data = (char *) must_malloc (n + 1); a->storage_as.string.data = (char *) must_malloc (n + 1);
...@@ -538,12 +492,12 @@ cons_array (LISP dim, LISP kind) ...@@ -538,12 +492,12 @@ cons_array (LISP dim, LISP kind)
else if EQ else if EQ
(cintern ("string"), kind) (cintern ("string"), kind)
{ {
a->type = tc_string_array; a->type = tc_string;
a->storage_as.string_array.dim = n; a->storage_as.string.dim = n;
a->storage_as.string_array.data = (char **) must_malloc (n * a->storage_as.string.data = (char *) must_malloc (n + 1);
sizeof (char *)); a->storage_as.string.data[n] = 0;
for (j = 0; j < n; ++j) for (j = 0; j < n; ++j)
a->storage_as.string_array.data[j] = 0; a->storage_as.string.data[j] = ' ';
} }
else if EQ else if EQ
(cintern ("byte"), kind) (cintern ("byte"), kind)
...@@ -935,15 +889,6 @@ array_equal (LISP a, LISP b) ...@@ -935,15 +889,6 @@ array_equal (LISP a, LISP b)
b->storage_as.double_array.data[j]) b->storage_as.double_array.data[j])
return (NIL); return (NIL);
return (sym_t); return (sym_t);
case tc_string_array:
len = a->storage_as.string_array.dim;
if (len != b->storage_as.string_array.dim)
return (NIL);
for (j = 0; j < len; ++j)
if (strcmp(a->storage_as.string_array.data[j],
b->storage_as.string_array.data[j]) != 0)
return (NIL);
return (sym_t);
case tc_lisp_array: case tc_lisp_array:
len = a->storage_as.lisp_array.dim; len = a->storage_as.lisp_array.dim;
if (len != b->storage_as.lisp_array.dim) if (len != b->storage_as.lisp_array.dim)
...@@ -962,7 +907,7 @@ array_equal (LISP a, LISP b) ...@@ -962,7 +907,7 @@ array_equal (LISP a, LISP b)
long long
array_sxhash (LISP a, long n) array_sxhash (LISP a, long n)
{ {
long i, j, len, hash; long j, len, hash;
unsigned char *char_data; unsigned char *char_data;
unsigned long *long_data; unsigned long *long_data;
double *double_data; double *double_data;
...@@ -990,19 +935,6 @@ array_sxhash (LISP a, long n) ...@@ -990,19 +935,6 @@ array_sxhash (LISP a, long n)
++j, ++double_data) ++j, ++double_data)
hash = HASH_COMBINE (hash, (unsigned long) *double_data % n, n); hash = HASH_COMBINE (hash, (unsigned long) *double_data % n, n);
return (hash); return (hash);
case tc_string_array:
hash = 0;
for (i = 0; i < a->storage_as.string_array.dim; ++i)
{
char_data = (unsigned char *) a->storage_as.string_array.data[i];
if (char_data != NULL)
{
len = strlen ((const char *) char_data);
for (j = 0; j < len; ++j)
hash = HASH_COMBINE (hash, *char_data++, n);
}
}
return (hash);
case tc_lisp_array: case tc_lisp_array:
len = a->storage_as.lisp_array.dim; len = a->storage_as.lisp_array.dim;
for (j = 0, hash = 0; j < len; ++j) for (j = 0, hash = 0; j < len; ++j)
...@@ -1303,18 +1235,6 @@ array_fast_print (LISP ptr, LISP table) ...@@ -1303,18 +1235,6 @@ array_fast_print (LISP ptr, LISP table)
put_long (len, f); put_long (len, f);
fwrite (ptr->storage_as.long_array.data, len, 1, f); fwrite (ptr->storage_as.long_array.data, len, 1, f);
return (NIL); return (NIL);
case tc_string_array:
putc (tc_string_array, f);
len = ptr->storage_as.long_array.dim;
put_long (len, f);
for (j = 0; j < ptr->storage_as.string_array.dim; ++j)
{
/* Add one to account for the NUL at the end of the string */
len = strlen (ptr->storage_as.string_array.data[j]) + 1;
put_long (len, f);
fwrite (ptr->storage_as.string_array.data[j], len, 1, f);
}
return (NIL);
case tc_lisp_array: case tc_lisp_array:
putc (tc_lisp_array, f); putc (tc_lisp_array, f);
len = ptr->storage_as.lisp_array.dim; len = ptr->storage_as.lisp_array.dim;
...@@ -1372,21 +1292,6 @@ array_fast_read (int code, LISP table) ...@@ -1372,21 +1292,6 @@ array_fast_read (int code, LISP table)
fread (ptr->storage_as.long_array.data, sizeof (long), len, f); fread (ptr->storage_as.long_array.data, sizeof (long), len, f);
no_interrupt (iflag); no_interrupt (iflag);
return (ptr); return (ptr);
case tc_string_array:
len = get_long (f);
iflag = no_interrupt (1);
ptr = newcell (tc_string_array);
ptr->storage_as.string_array.dim = len;
ptr->storage_as.string_array.data =
(char **) must_malloc (len * sizeof (char *));
for (j = 0; j < ptr->storage_as.string_array.dim; ++j)
{
len = get_long (f);
ptr->storage_as.string_array.data[j] = must_malloc (len);
fread (ptr->storage_as.string_array.data[j], len, 1, f);
}
no_interrupt (iflag);
return (ptr);
case tc_lisp_array: case tc_lisp_array:
len = get_long (f); len = get_long (f);
FLONM (bashnum) = len; FLONM (bashnum) = len;
...@@ -1548,8 +1453,6 @@ nlength (LISP obj) ...@@ -1548,8 +1453,6 @@ nlength (LISP obj)
return (obj->storage_as.double_array.dim); return (obj->storage_as.double_array.dim);
case tc_long_array: case tc_long_array:
return (obj->storage_as.long_array.dim); return (obj->storage_as.long_array.dim);
case tc_string_array:
return (obj->storage_as.string_array.dim);
case tc_lisp_array: case tc_lisp_array:
return (obj->storage_as.lisp_array.dim); return (obj->storage_as.lisp_array.dim);
case tc_nil: case tc_nil:
...@@ -2674,8 +2577,6 @@ ltypeof (LISP obj) ...@@ -2674,8 +2577,6 @@ ltypeof (LISP obj)
return (cintern ("tc_double_array")); return (cintern ("tc_double_array"));
case tc_long_array: case tc_long_array:
return (cintern ("tc_long_array")); return (cintern ("tc_long_array"));
case tc_string_array:
return (cintern ("tc_string_array"));
case tc_lisp_array: case tc_lisp_array:
return (cintern ("tc_lisp_array")); return (cintern ("tc_lisp_array"));
case tc_c_file: case tc_c_file:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment