comparison src/search.c @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 0132846995bd
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
172:a38aed19690b 173:8eaf7971accc
1142 /* And bufpos too. */ 1142 /* And bufpos too. */
1143 bufpos = search_regs.start[0]; 1143 bufpos = search_regs.start[0];
1144 } 1144 }
1145 else 1145 else
1146 { 1146 {
1147 return (n); 1147 return n;
1148 } 1148 }
1149 n++; 1149 n++;
1150 } 1150 }
1151 while (n > 0) 1151 while (n > 0)
1152 { 1152 {
1178 /* And bufpos too. */ 1178 /* And bufpos too. */
1179 bufpos = search_regs.end[0]; 1179 bufpos = search_regs.end[0];
1180 } 1180 }
1181 else 1181 else
1182 { 1182 {
1183 return (0 - n); 1183 return 0 - n;
1184 } 1184 }
1185 n--; 1185 n--;
1186 } 1186 }
1187 return (bufpos); 1187 return bufpos;
1188 } 1188 }
1189 else /* non-RE case */ 1189 else /* non-RE case */
1190 /* #### Someone really really really needs to comment the workings 1190 /* #### Someone really really really needs to comment the workings
1191 of this junk somewhat better. 1191 of this junk somewhat better.
1192 1192
1321 { 1321 {
1322 /* It's been reported that some (broken) compiler thinks that 1322 /* It's been reported that some (broken) compiler thinks that
1323 Boolean expressions in an arithmetic context are unsigned. 1323 Boolean expressions in an arithmetic context are unsigned.
1324 Using an explicit ?1:0 prevents this. */ 1324 Using an explicit ?1:0 prevents this. */
1325 if ((lim - pos - ((direction > 0) ? 1 : 0)) * direction < 0) 1325 if ((lim - pos - ((direction > 0) ? 1 : 0)) * direction < 0)
1326 return (n * (0 - direction)); 1326 return n * (0 - direction);
1327 /* First we do the part we can by pointers (maybe nothing) */ 1327 /* First we do the part we can by pointers (maybe nothing) */
1328 QUIT; 1328 QUIT;
1329 pat = base_pat; 1329 pat = base_pat;
1330 limit = pos - dirlen + direction; 1330 limit = pos - dirlen + direction;
1331 /* XEmacs change: definitions of CEILING_OF and FLOOR_OF 1331 /* XEmacs change: definitions of CEILING_OF and FLOOR_OF
1493 pos += stride_for_teases; 1493 pos += stride_for_teases;
1494 } 1494 }
1495 } 1495 }
1496 /* We have done one clump. Can we continue? */ 1496 /* We have done one clump. Can we continue? */
1497 if ((lim - pos) * direction < 0) 1497 if ((lim - pos) * direction < 0)
1498 return ((0 - n) * direction); 1498 return (0 - n) * direction;
1499 } 1499 }
1500 return bytind_to_bufpos (buf, pos); 1500 return bytind_to_bufpos (buf, pos);
1501 } 1501 }
1502 } 1502 }
1503 1503
1954 (the end of literal text to be inserted). */ 1954 (the end of literal text to be inserted). */
1955 Charcount literal_end = -1; 1955 Charcount literal_end = -1;
1956 /* If SUBSTART is set, we need to also insert the 1956 /* If SUBSTART is set, we need to also insert the
1957 text from SUBSTART to SUBEND in the original string. */ 1957 text from SUBSTART to SUBEND in the original string. */
1958 Charcount substart = -1; 1958 Charcount substart = -1;
1959 Charcount subend; 1959 Charcount subend = -1;
1960 1960
1961 c = string_char (XSTRING (newtext), strpos); 1961 c = string_char (XSTRING (newtext), strpos);
1962 if (c == '\\') 1962 if (c == '\\')
1963 { 1963 {
1964 c = string_char (XSTRING (newtext), ++strpos); 1964 c = string_char (XSTRING (newtext), ++strpos);
2213 2213
2214 CHECK_INT (num); 2214 CHECK_INT (num);
2215 n = XINT (num); 2215 n = XINT (num);
2216 if (n < 0 || n >= search_regs.num_regs) 2216 if (n < 0 || n >= search_regs.num_regs)
2217 args_out_of_range (num, make_int (search_regs.num_regs)); 2217 args_out_of_range (num, make_int (search_regs.num_regs));
2218 if (search_regs.num_regs <= 0 2218 if (search_regs.num_regs <= 0 ||
2219 || search_regs.start[n] < 0) 2219 search_regs.start[n] < 0)
2220 return Qnil; 2220 return Qnil;
2221 return (make_int ((beginningp) ? search_regs.start[n] 2221 return make_int (beginningp ? search_regs.start[n] : search_regs.end[n]);
2222 : search_regs.end[n]));
2223 } 2222 }
2224 2223
2225 DEFUN ("match-beginning", Fmatch_beginning, 1, 1, 0, /* 2224 DEFUN ("match-beginning", Fmatch_beginning, 1, 1, 0, /*
2226 Return position of start of text matched by last regexp search. 2225 Return position of start of text matched by last regexp search.
2227 NUM, specifies which parenthesized expression in the last regexp. 2226 NUM, specifies which parenthesized expression in the last regexp.