comparison src/regex.c @ 29801:3ea64112b4ba

(re_match, re_match_2): Protect calls to alloca (0). (re_comp): Cast gettext return value to avoid complaints when !HAVE_LIBINTL.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 20 Jun 2000 16:48:05 +0000
parents fbe764633971
children db737e34fc36
comparison
equal deleted inserted replaced
29800:b64123677c0b 29801:3ea64112b4ba
4289 int size, pos; 4289 int size, pos;
4290 struct re_registers *regs; 4290 struct re_registers *regs;
4291 { 4291 {
4292 int result = re_match_2_internal (bufp, NULL, 0, string, size, 4292 int result = re_match_2_internal (bufp, NULL, 0, string, size,
4293 pos, regs, size); 4293 pos, regs, size);
4294 #if defined (C_ALLOCA) && !defined (REGEX_MALLOC)
4294 alloca (0); 4295 alloca (0);
4296 #endif
4295 return result; 4297 return result;
4296 } 4298 }
4297 #endif /* not emacs */ 4299 #endif /* not emacs */
4298 4300
4299 #ifdef emacs 4301 #ifdef emacs
4333 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); 4335 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
4334 #endif 4336 #endif
4335 4337
4336 result = re_match_2_internal (bufp, string1, size1, string2, size2, 4338 result = re_match_2_internal (bufp, string1, size1, string2, size2,
4337 pos, regs, stop); 4339 pos, regs, stop);
4340 #if defined (C_ALLOCA) && !defined (REGEX_MALLOC)
4338 alloca (0); 4341 alloca (0);
4342 #endif
4339 return result; 4343 return result;
4340 } 4344 }
4341 4345
4342 /* This is a separate function so that we can force an alloca cleanup 4346 /* This is a separate function so that we can force an alloca cleanup
4343 afterwards. */ 4347 afterwards. */
5591 reg_errcode_t ret; 5595 reg_errcode_t ret;
5592 5596
5593 if (!s) 5597 if (!s)
5594 { 5598 {
5595 if (!re_comp_buf.buffer) 5599 if (!re_comp_buf.buffer)
5596 return gettext ("No previous regular expression"); 5600 /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
5601 return (char *) gettext ("No previous regular expression");
5597 return 0; 5602 return 0;
5598 } 5603 }
5599 5604
5600 if (!re_comp_buf.buffer) 5605 if (!re_comp_buf.buffer)
5601 { 5606 {
5602 re_comp_buf.buffer = (unsigned char *) malloc (200); 5607 re_comp_buf.buffer = (unsigned char *) malloc (200);
5603 if (re_comp_buf.buffer == NULL) 5608 if (re_comp_buf.buffer == NULL)
5604 return gettext (re_error_msgid[(int) REG_ESPACE]); 5609 /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
5610 return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
5605 re_comp_buf.allocated = 200; 5611 re_comp_buf.allocated = 200;
5606 5612
5607 re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); 5613 re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
5608 if (re_comp_buf.fastmap == NULL) 5614 if (re_comp_buf.fastmap == NULL)
5609 return gettext (re_error_msgid[(int) REG_ESPACE]); 5615 /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
5616 return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
5610 } 5617 }
5611 5618
5612 /* Since `re_exec' always passes NULL for the `regs' argument, we 5619 /* Since `re_exec' always passes NULL for the `regs' argument, we
5613 don't need to initialize the pattern buffer fields which affect it. */ 5620 don't need to initialize the pattern buffer fields which affect it. */
5614 5621