comparison src/fns.c @ 110543:a89eabac600d

Fix int/EMACS_INT usage in fns.c. fns.c (Fcompare_strings, Fstring_lessp, concat) (string_make_unibyte, Fstring_as_unibyte, Fsubstring) (Fsubstring_no_properties, substring_both, Ffillarray) (Fclear_string, mapcar1, Fmapconcat, Fmapcar, Fmapc) (Fbase64_encode_region, Fbase64_encode_string, base64_encode_1) (Fbase64_decode_region, Fbase64_decode_string, base64_decode_1) (Fmd5): Use EMACS_INT for buffer and string positions and length variables and arguments. <struct textprop_rec>: Use EMACS_INT for positions. lisp.h (substring_both): Adjust prototype.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 24 Sep 2010 07:55:44 -0400
parents fda36a325177
children ac49e05bfcf2
comparison
equal deleted inserted replaced
110542:93f2c2c37f24 110543:a89eabac600d
239 - 1 - N is the number of characters that match at the beginning. 239 - 1 - N is the number of characters that match at the beginning.
240 If string STR1 is greater, the value is a positive number N; 240 If string STR1 is greater, the value is a positive number N;
241 N - 1 is the number of characters that match at the beginning. */) 241 N - 1 is the number of characters that match at the beginning. */)
242 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case) 242 (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case)
243 { 243 {
244 register int end1_char, end2_char; 244 register EMACS_INT end1_char, end2_char;
245 register int i1, i1_byte, i2, i2_byte; 245 register EMACS_INT i1, i1_byte, i2, i2_byte;
246 246
247 CHECK_STRING (str1); 247 CHECK_STRING (str1);
248 CHECK_STRING (str2); 248 CHECK_STRING (str2);
249 if (NILP (start1)) 249 if (NILP (start1))
250 start1 = make_number (0); 250 start1 = make_number (0);
330 doc: /* Return t if first arg string is less than second in lexicographic order. 330 doc: /* Return t if first arg string is less than second in lexicographic order.
331 Case is significant. 331 Case is significant.
332 Symbols are also allowed; their print names are used instead. */) 332 Symbols are also allowed; their print names are used instead. */)
333 (register Lisp_Object s1, Lisp_Object s2) 333 (register Lisp_Object s1, Lisp_Object s2)
334 { 334 {
335 register int end; 335 register EMACS_INT end;
336 register int i1, i1_byte, i2, i2_byte; 336 register EMACS_INT i1, i1_byte, i2, i2_byte;
337 337
338 if (SYMBOLP (s1)) 338 if (SYMBOLP (s1))
339 s1 = SYMBOL_NAME (s1); 339 s1 = SYMBOL_NAME (s1);
340 if (SYMBOLP (s2)) 340 if (SYMBOLP (s2))
341 s2 = SYMBOL_NAME (s2); 341 s2 = SYMBOL_NAME (s2);
454 /* This structure holds information of an argument of `concat' that is 454 /* This structure holds information of an argument of `concat' that is
455 a string and has text properties to be copied. */ 455 a string and has text properties to be copied. */
456 struct textprop_rec 456 struct textprop_rec
457 { 457 {
458 int argnum; /* refer to ARGS (arguments of `concat') */ 458 int argnum; /* refer to ARGS (arguments of `concat') */
459 int from; /* refer to ARGS[argnum] (argument string) */ 459 EMACS_INT from; /* refer to ARGS[argnum] (argument string) */
460 int to; /* refer to VAL (the target string) */ 460 EMACS_INT to; /* refer to VAL (the target string) */
461 }; 461 };
462 462
463 static Lisp_Object 463 static Lisp_Object
464 concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special) 464 concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)
465 { 465 {
466 Lisp_Object val; 466 Lisp_Object val;
467 register Lisp_Object tail; 467 register Lisp_Object tail;
468 register Lisp_Object this; 468 register Lisp_Object this;
469 int toindex; 469 EMACS_INT toindex;
470 int toindex_byte = 0; 470 EMACS_INT toindex_byte = 0;
471 register int result_len; 471 register EMACS_INT result_len;
472 register int result_len_byte; 472 register EMACS_INT result_len_byte;
473 register int argnum; 473 register int argnum;
474 Lisp_Object last_tail; 474 Lisp_Object last_tail;
475 Lisp_Object prev; 475 Lisp_Object prev;
476 int some_multibyte; 476 int some_multibyte;
477 /* When we make a multibyte string, we can't copy text properties 477 /* When we make a multibyte string, we can't copy text properties
511 result_len_byte = 0; 511 result_len_byte = 0;
512 result_len = 0; 512 result_len = 0;
513 some_multibyte = 0; 513 some_multibyte = 0;
514 for (argnum = 0; argnum < nargs; argnum++) 514 for (argnum = 0; argnum < nargs; argnum++)
515 { 515 {
516 int len; 516 EMACS_INT len;
517 this = args[argnum]; 517 this = args[argnum];
518 len = XFASTINT (Flength (this)); 518 len = XFASTINT (Flength (this));
519 if (target_type == Lisp_String) 519 if (target_type == Lisp_String)
520 { 520 {
521 /* We must count the number of bytes needed in the string 521 /* We must count the number of bytes needed in the string
522 as well as the number of characters. */ 522 as well as the number of characters. */
523 int i; 523 EMACS_INT i;
524 Lisp_Object ch; 524 Lisp_Object ch;
525 int this_len_byte; 525 EMACS_INT this_len_byte;
526 526
527 if (VECTORP (this)) 527 if (VECTORP (this))
528 for (i = 0; i < len; i++) 528 for (i = 0; i < len; i++)
529 { 529 {
530 ch = AREF (this, i); 530 ch = AREF (this, i);
592 SAFE_ALLOCA (textprops, struct textprop_rec *, sizeof (struct textprop_rec) * nargs); 592 SAFE_ALLOCA (textprops, struct textprop_rec *, sizeof (struct textprop_rec) * nargs);
593 593
594 for (argnum = 0; argnum < nargs; argnum++) 594 for (argnum = 0; argnum < nargs; argnum++)
595 { 595 {
596 Lisp_Object thislen; 596 Lisp_Object thislen;
597 int thisleni = 0; 597 EMACS_INT thisleni = 0;
598 register unsigned int thisindex = 0; 598 register EMACS_INT thisindex = 0;
599 register unsigned int thisindex_byte = 0; 599 register EMACS_INT thisindex_byte = 0;
600 600
601 this = args[argnum]; 601 this = args[argnum];
602 if (!CONSP (this)) 602 if (!CONSP (this))
603 thislen = Flength (this), thisleni = XINT (thislen); 603 thislen = Flength (this), thisleni = XINT (thislen);
604 604
605 /* Between strings of the same kind, copy fast. */ 605 /* Between strings of the same kind, copy fast. */
606 if (STRINGP (this) && STRINGP (val) 606 if (STRINGP (this) && STRINGP (val)
607 && STRING_MULTIBYTE (this) == some_multibyte) 607 && STRING_MULTIBYTE (this) == some_multibyte)
608 { 608 {
609 int thislen_byte = SBYTES (this); 609 EMACS_INT thislen_byte = SBYTES (this);
610 610
611 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); 611 memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this));
612 if (! NULL_INTERVAL_P (STRING_INTERVALS (this))) 612 if (! NULL_INTERVAL_P (STRING_INTERVALS (this)))
613 { 613 {
614 textprops[num_textprops].argnum = argnum; 614 textprops[num_textprops].argnum = argnum;
711 XSETCDR (prev, last_tail); 711 XSETCDR (prev, last_tail);
712 712
713 if (num_textprops > 0) 713 if (num_textprops > 0)
714 { 714 {
715 Lisp_Object props; 715 Lisp_Object props;
716 int last_to_end = -1; 716 EMACS_INT last_to_end = -1;
717 717
718 for (argnum = 0; argnum < num_textprops; argnum++) 718 for (argnum = 0; argnum < num_textprops; argnum++)
719 { 719 {
720 this = args[textprops[argnum].argnum]; 720 this = args[textprops[argnum].argnum];
721 props = text_property_list (this, 721 props = text_property_list (this,
936 /* Convert STRING to a single-byte string. */ 936 /* Convert STRING to a single-byte string. */
937 937
938 Lisp_Object 938 Lisp_Object
939 string_make_unibyte (Lisp_Object string) 939 string_make_unibyte (Lisp_Object string)
940 { 940 {
941 int nchars; 941 EMACS_INT nchars;
942 unsigned char *buf; 942 unsigned char *buf;
943 Lisp_Object ret; 943 Lisp_Object ret;
944 USE_SAFE_ALLOCA; 944 USE_SAFE_ALLOCA;
945 945
946 if (! STRING_MULTIBYTE (string)) 946 if (! STRING_MULTIBYTE (string))
1001 { 1001 {
1002 CHECK_STRING (string); 1002 CHECK_STRING (string);
1003 1003
1004 if (STRING_MULTIBYTE (string)) 1004 if (STRING_MULTIBYTE (string))
1005 { 1005 {
1006 int bytes = SBYTES (string); 1006 EMACS_INT bytes = SBYTES (string);
1007 unsigned char *str = (unsigned char *) xmalloc (bytes); 1007 unsigned char *str = (unsigned char *) xmalloc (bytes);
1008 1008
1009 memcpy (str, SDATA (string), bytes); 1009 memcpy (str, SDATA (string), bytes);
1010 bytes = str_as_unibyte (str, bytes); 1010 bytes = str_as_unibyte (str, bytes);
1011 string = make_unibyte_string (str, bytes); 1011 string = make_unibyte_string (str, bytes);
1136 value is a new vector that contains the elements between index FROM 1136 value is a new vector that contains the elements between index FROM
1137 \(inclusive) and index TO (exclusive) of that vector argument. */) 1137 \(inclusive) and index TO (exclusive) of that vector argument. */)
1138 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1138 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1139 { 1139 {
1140 Lisp_Object res; 1140 Lisp_Object res;
1141 int size; 1141 EMACS_INT size;
1142 int size_byte = 0; 1142 EMACS_INT size_byte = 0;
1143 int from_char, to_char; 1143 EMACS_INT from_char, to_char;
1144 int from_byte = 0, to_byte = 0; 1144 EMACS_INT from_byte = 0, to_byte = 0;
1145 1145
1146 CHECK_VECTOR_OR_STRING (string); 1146 CHECK_VECTOR_OR_STRING (string);
1147 CHECK_NUMBER (from); 1147 CHECK_NUMBER (from);
1148 1148
1149 if (STRINGP (string)) 1149 if (STRINGP (string))
1204 If FROM or TO is negative, it counts from the end. 1204 If FROM or TO is negative, it counts from the end.
1205 1205
1206 With one argument, just copy STRING without its properties. */) 1206 With one argument, just copy STRING without its properties. */)
1207 (Lisp_Object string, register Lisp_Object from, Lisp_Object to) 1207 (Lisp_Object string, register Lisp_Object from, Lisp_Object to)
1208 { 1208 {
1209 int size, size_byte; 1209 EMACS_INT size, size_byte;
1210 int from_char, to_char; 1210 EMACS_INT from_char, to_char;
1211 int from_byte, to_byte; 1211 EMACS_INT from_byte, to_byte;
1212 1212
1213 CHECK_STRING (string); 1213 CHECK_STRING (string);
1214 1214
1215 size = SCHARS (string); 1215 size = SCHARS (string);
1216 size_byte = SBYTES (string); 1216 size_byte = SBYTES (string);
1254 1254
1255 /* Extract a substring of STRING, giving start and end positions 1255 /* Extract a substring of STRING, giving start and end positions
1256 both in characters and in bytes. */ 1256 both in characters and in bytes. */
1257 1257
1258 Lisp_Object 1258 Lisp_Object
1259 substring_both (Lisp_Object string, int from, int from_byte, int to, int to_byte) 1259 substring_both (Lisp_Object string, EMACS_INT from, EMACS_INT from_byte,
1260 EMACS_INT to, EMACS_INT to_byte)
1260 { 1261 {
1261 Lisp_Object res; 1262 Lisp_Object res;
1262 int size; 1263 EMACS_INT size;
1263 int size_byte; 1264 EMACS_INT size_byte;
1264 1265
1265 CHECK_VECTOR_OR_STRING (string); 1266 CHECK_VECTOR_OR_STRING (string);
1266 1267
1267 if (STRINGP (string)) 1268 if (STRINGP (string))
1268 { 1269 {
2145 DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, 2146 DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
2146 doc: /* Store each element of ARRAY with ITEM. 2147 doc: /* Store each element of ARRAY with ITEM.
2147 ARRAY is a vector, string, char-table, or bool-vector. */) 2148 ARRAY is a vector, string, char-table, or bool-vector. */)
2148 (Lisp_Object array, Lisp_Object item) 2149 (Lisp_Object array, Lisp_Object item)
2149 { 2150 {
2150 register int size, index, charval; 2151 register EMACS_INT size, index;
2152 int charval;
2153
2151 if (VECTORP (array)) 2154 if (VECTORP (array))
2152 { 2155 {
2153 register Lisp_Object *p = XVECTOR (array)->contents; 2156 register Lisp_Object *p = XVECTOR (array)->contents;
2154 size = ASIZE (array); 2157 size = ASIZE (array);
2155 for (index = 0; index < size; index++) 2158 for (index = 0; index < size; index++)
2171 size = SCHARS (array); 2174 size = SCHARS (array);
2172 if (STRING_MULTIBYTE (array)) 2175 if (STRING_MULTIBYTE (array))
2173 { 2176 {
2174 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2177 unsigned char str[MAX_MULTIBYTE_LENGTH];
2175 int len = CHAR_STRING (charval, str); 2178 int len = CHAR_STRING (charval, str);
2176 int size_byte = SBYTES (array); 2179 EMACS_INT size_byte = SBYTES (array);
2177 unsigned char *p1 = p, *endp = p + size_byte; 2180 unsigned char *p1 = p, *endp = p + size_byte;
2178 int i; 2181 int i;
2179 2182
2180 if (size != size_byte) 2183 if (size != size_byte)
2181 while (p1 < endp) 2184 while (p1 < endp)
2219 1, 1, 0, 2222 1, 1, 0,
2220 doc: /* Clear the contents of STRING. 2223 doc: /* Clear the contents of STRING.
2221 This makes STRING unibyte and may change its length. */) 2224 This makes STRING unibyte and may change its length. */)
2222 (Lisp_Object string) 2225 (Lisp_Object string)
2223 { 2226 {
2224 int len; 2227 EMACS_INT len;
2225 CHECK_STRING (string); 2228 CHECK_STRING (string);
2226 len = SBYTES (string); 2229 len = SBYTES (string);
2227 memset (SDATA (string), 0, len); 2230 memset (SDATA (string), 0, len);
2228 STRING_SET_CHARS (string, len); 2231 STRING_SET_CHARS (string, len);
2229 STRING_SET_UNIBYTE (string); 2232 STRING_SET_UNIBYTE (string);
2283 Apply FN to each element of SEQ, one by one, 2286 Apply FN to each element of SEQ, one by one,
2284 storing the results into elements of VALS, a C vector of Lisp_Objects. 2287 storing the results into elements of VALS, a C vector of Lisp_Objects.
2285 LENI is the length of VALS, which should also be the length of SEQ. */ 2288 LENI is the length of VALS, which should also be the length of SEQ. */
2286 2289
2287 static void 2290 static void
2288 mapcar1 (int leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq) 2291 mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
2289 { 2292 {
2290 register Lisp_Object tail; 2293 register Lisp_Object tail;
2291 Lisp_Object dummy; 2294 Lisp_Object dummy;
2292 register int i; 2295 register EMACS_INT i;
2293 struct gcpro gcpro1, gcpro2, gcpro3; 2296 struct gcpro gcpro1, gcpro2, gcpro3;
2294 2297
2295 if (vals) 2298 if (vals)
2296 { 2299 {
2297 /* Don't let vals contain any garbage when GC happens. */ 2300 /* Don't let vals contain any garbage when GC happens. */
2329 vals[i] = dummy; 2332 vals[i] = dummy;
2330 } 2333 }
2331 } 2334 }
2332 else if (STRINGP (seq)) 2335 else if (STRINGP (seq))
2333 { 2336 {
2334 int i_byte; 2337 EMACS_INT i_byte;
2335 2338
2336 for (i = 0, i_byte = 0; i < leni;) 2339 for (i = 0, i_byte = 0; i < leni;)
2337 { 2340 {
2338 int c; 2341 int c;
2339 int i_before = i; 2342 EMACS_INT i_before = i;
2340 2343
2341 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte); 2344 FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte);
2342 XSETFASTINT (dummy, c); 2345 XSETFASTINT (dummy, c);
2343 dummy = call1 (fn, dummy); 2346 dummy = call1 (fn, dummy);
2344 if (vals) 2347 if (vals)
2366 SEPARATOR results in spaces between the values returned by FUNCTION. 2369 SEPARATOR results in spaces between the values returned by FUNCTION.
2367 SEQUENCE may be a list, a vector, a bool-vector, or a string. */) 2370 SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2368 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator) 2371 (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
2369 { 2372 {
2370 Lisp_Object len; 2373 Lisp_Object len;
2371 register int leni; 2374 register EMACS_INT leni;
2372 int nargs; 2375 int nargs;
2373 register Lisp_Object *args; 2376 register Lisp_Object *args;
2374 register int i; 2377 register EMACS_INT i;
2375 struct gcpro gcpro1; 2378 struct gcpro gcpro1;
2376 Lisp_Object ret; 2379 Lisp_Object ret;
2377 USE_SAFE_ALLOCA; 2380 USE_SAFE_ALLOCA;
2378 2381
2379 len = Flength (sequence); 2382 len = Flength (sequence);
2406 The result is a list just as long as SEQUENCE. 2409 The result is a list just as long as SEQUENCE.
2407 SEQUENCE may be a list, a vector, a bool-vector, or a string. */) 2410 SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2408 (Lisp_Object function, Lisp_Object sequence) 2411 (Lisp_Object function, Lisp_Object sequence)
2409 { 2412 {
2410 register Lisp_Object len; 2413 register Lisp_Object len;
2411 register int leni; 2414 register EMACS_INT leni;
2412 register Lisp_Object *args; 2415 register Lisp_Object *args;
2413 Lisp_Object ret; 2416 Lisp_Object ret;
2414 USE_SAFE_ALLOCA; 2417 USE_SAFE_ALLOCA;
2415 2418
2416 len = Flength (sequence); 2419 len = Flength (sequence);
2432 doc: /* Apply FUNCTION to each element of SEQUENCE for side effects only. 2435 doc: /* Apply FUNCTION to each element of SEQUENCE for side effects only.
2433 Unlike `mapcar', don't accumulate the results. Return SEQUENCE. 2436 Unlike `mapcar', don't accumulate the results. Return SEQUENCE.
2434 SEQUENCE may be a list, a vector, a bool-vector, or a string. */) 2437 SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
2435 (Lisp_Object function, Lisp_Object sequence) 2438 (Lisp_Object function, Lisp_Object sequence)
2436 { 2439 {
2437 register int leni; 2440 register EMACS_INT leni;
2438 2441
2439 leni = XFASTINT (Flength (sequence)); 2442 leni = XFASTINT (Flength (sequence));
2440 if (CHAR_TABLE_P (sequence)) 2443 if (CHAR_TABLE_P (sequence))
2441 wrong_type_argument (Qlistp, sequence); 2444 wrong_type_argument (Qlistp, sequence);
2442 mapcar1 (leni, 0, function, sequence); 2445 mapcar1 (leni, 0, function, sequence);
2956 2959
2957 The octets are divided into 6 bit chunks, which are then encoded into 2960 The octets are divided into 6 bit chunks, which are then encoded into
2958 base64 characters. */ 2961 base64 characters. */
2959 2962
2960 2963
2961 static int base64_encode_1 (const char *, char *, int, int, int); 2964 static EMACS_INT base64_encode_1 (const char *, char *, EMACS_INT, int, int);
2962 static int base64_decode_1 (const char *, char *, int, int, int *); 2965 static EMACS_INT base64_decode_1 (const char *, char *, EMACS_INT, int,
2966 EMACS_INT *);
2963 2967
2964 DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2968 DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
2965 2, 3, "r", 2969 2, 3, "r",
2966 doc: /* Base64-encode the region between BEG and END. 2970 doc: /* Base64-encode the region between BEG and END.
2967 Return the length of the encoded text. 2971 Return the length of the encoded text.
2968 Optional third argument NO-LINE-BREAK means do not break long lines 2972 Optional third argument NO-LINE-BREAK means do not break long lines
2969 into shorter lines. */) 2973 into shorter lines. */)
2970 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) 2974 (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break)
2971 { 2975 {
2972 char *encoded; 2976 char *encoded;
2973 int allength, length; 2977 EMACS_INT allength, length;
2974 int ibeg, iend, encoded_length; 2978 EMACS_INT ibeg, iend, encoded_length;
2975 int old_pos = PT; 2979 EMACS_INT old_pos = PT;
2976 USE_SAFE_ALLOCA; 2980 USE_SAFE_ALLOCA;
2977 2981
2978 validate_region (&beg, &end); 2982 validate_region (&beg, &end);
2979 2983
2980 ibeg = CHAR_TO_BYTE (XFASTINT (beg)); 2984 ibeg = CHAR_TO_BYTE (XFASTINT (beg));
3026 doc: /* Base64-encode STRING and return the result. 3030 doc: /* Base64-encode STRING and return the result.
3027 Optional second argument NO-LINE-BREAK means do not break long lines 3031 Optional second argument NO-LINE-BREAK means do not break long lines
3028 into shorter lines. */) 3032 into shorter lines. */)
3029 (Lisp_Object string, Lisp_Object no_line_break) 3033 (Lisp_Object string, Lisp_Object no_line_break)
3030 { 3034 {
3031 int allength, length, encoded_length; 3035 EMACS_INT allength, length, encoded_length;
3032 char *encoded; 3036 char *encoded;
3033 Lisp_Object encoded_string; 3037 Lisp_Object encoded_string;
3034 USE_SAFE_ALLOCA; 3038 USE_SAFE_ALLOCA;
3035 3039
3036 CHECK_STRING (string); 3040 CHECK_STRING (string);
3062 SAFE_FREE (); 3066 SAFE_FREE ();
3063 3067
3064 return encoded_string; 3068 return encoded_string;
3065 } 3069 }
3066 3070
3067 static int 3071 static EMACS_INT
3068 base64_encode_1 (const char *from, char *to, int length, int line_break, int multibyte) 3072 base64_encode_1 (const char *from, char *to, EMACS_INT length,
3069 { 3073 int line_break, int multibyte)
3070 int counter = 0, i = 0; 3074 {
3075 int counter = 0;
3076 EMACS_INT i = 0;
3071 char *e = to; 3077 char *e = to;
3072 int c; 3078 int c;
3073 unsigned int value; 3079 unsigned int value;
3074 int bytes; 3080 int bytes;
3075 3081
3164 doc: /* Base64-decode the region between BEG and END. 3170 doc: /* Base64-decode the region between BEG and END.
3165 Return the length of the decoded text. 3171 Return the length of the decoded text.
3166 If the region can't be decoded, signal an error and don't modify the buffer. */) 3172 If the region can't be decoded, signal an error and don't modify the buffer. */)
3167 (Lisp_Object beg, Lisp_Object end) 3173 (Lisp_Object beg, Lisp_Object end)
3168 { 3174 {
3169 int ibeg, iend, length, allength; 3175 EMACS_INT ibeg, iend, length, allength;
3170 char *decoded; 3176 char *decoded;
3171 int old_pos = PT; 3177 EMACS_INT old_pos = PT;
3172 int decoded_length; 3178 EMACS_INT decoded_length;
3173 int inserted_chars; 3179 EMACS_INT inserted_chars;
3174 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 3180 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
3175 USE_SAFE_ALLOCA; 3181 USE_SAFE_ALLOCA;
3176 3182
3177 validate_region (&beg, &end); 3183 validate_region (&beg, &end);
3178 3184
3225 1, 1, 0, 3231 1, 1, 0,
3226 doc: /* Base64-decode STRING and return the result. */) 3232 doc: /* Base64-decode STRING and return the result. */)
3227 (Lisp_Object string) 3233 (Lisp_Object string)
3228 { 3234 {
3229 char *decoded; 3235 char *decoded;
3230 int length, decoded_length; 3236 EMACS_INT length, decoded_length;
3231 Lisp_Object decoded_string; 3237 Lisp_Object decoded_string;
3232 USE_SAFE_ALLOCA; 3238 USE_SAFE_ALLOCA;
3233 3239
3234 CHECK_STRING (string); 3240 CHECK_STRING (string);
3235 3241
3257 /* Base64-decode the data at FROM of LENGHT bytes into TO. If 3263 /* Base64-decode the data at FROM of LENGHT bytes into TO. If
3258 MULTIBYTE is nonzero, the decoded result should be in multibyte 3264 MULTIBYTE is nonzero, the decoded result should be in multibyte
3259 form. If NCHARS_RETRUN is not NULL, store the number of produced 3265 form. If NCHARS_RETRUN is not NULL, store the number of produced
3260 characters in *NCHARS_RETURN. */ 3266 characters in *NCHARS_RETURN. */
3261 3267
3262 static int 3268 static EMACS_INT
3263 base64_decode_1 (const char *from, char *to, int length, int multibyte, int *nchars_return) 3269 base64_decode_1 (const char *from, char *to, EMACS_INT length,
3264 { 3270 int multibyte, EMACS_INT *nchars_return)
3265 int i = 0; 3271 {
3272 EMACS_INT i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3266 char *e = to; 3273 char *e = to;
3267 unsigned char c; 3274 unsigned char c;
3268 unsigned long value; 3275 unsigned long value;
3269 int nchars = 0; 3276 EMACS_INT nchars = 0;
3270 3277
3271 while (1) 3278 while (1)
3272 { 3279 {
3273 /* Process first byte of a quadruplet. */ 3280 /* Process first byte of a quadruplet. */
3274 3281
4570 (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror) 4577 (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror)
4571 { 4578 {
4572 unsigned char digest[16]; 4579 unsigned char digest[16];
4573 unsigned char value[33]; 4580 unsigned char value[33];
4574 int i; 4581 int i;
4575 int size; 4582 EMACS_INT size;
4576 int size_byte = 0; 4583 EMACS_INT size_byte = 0;
4577 int start_char = 0, end_char = 0; 4584 EMACS_INT start_char = 0, end_char = 0;
4578 int start_byte = 0, end_byte = 0; 4585 EMACS_INT start_byte = 0, end_byte = 0;
4579 register int b, e; 4586 register EMACS_INT b, e;
4580 register struct buffer *bp; 4587 register struct buffer *bp;
4581 int temp; 4588 EMACS_INT temp;
4582 4589
4583 if (STRINGP (object)) 4590 if (STRINGP (object))
4584 { 4591 {
4585 if (NILP (coding_system)) 4592 if (NILP (coding_system))
4586 { 4593 {