Mercurial > vim
comparison src/ex_cmds.c @ 834:5117153003bd v7.0e
updated for version 7.0e
author | vimboss |
---|---|
date | Sun, 16 Apr 2006 18:30:08 +0000 |
parents | 1cdd2661f34c |
children | 8bebcabccc2c |
comparison
equal
deleted
inserted
replaced
833:52d17d53b555 | 834:5117153003bd |
---|---|
297 sorti_T l1 = *(sorti_T *)s1; | 297 sorti_T l1 = *(sorti_T *)s1; |
298 sorti_T l2 = *(sorti_T *)s2; | 298 sorti_T l2 = *(sorti_T *)s2; |
299 int result = 0; | 299 int result = 0; |
300 | 300 |
301 /* If the user interrupts, there's no way to stop qsort() immediately, but | 301 /* If the user interrupts, there's no way to stop qsort() immediately, but |
302 * if we return 0 every time, qsort will assume it's done sorting and exit */ | 302 * if we return 0 every time, qsort will assume it's done sorting and |
303 * exit. */ | |
303 if (sort_abort) | 304 if (sort_abort) |
304 return 0; | 305 return 0; |
305 fast_breakcheck(); | 306 fast_breakcheck(); |
306 if (got_int) | 307 if (got_int) |
307 sort_abort = TRUE; | 308 sort_abort = TRUE; |
308 | 309 |
309 /* When sorting numbers "start_col_nr" is the number, not the column number. */ | 310 /* When sorting numbers "start_col_nr" is the number, not the column |
311 * number. */ | |
310 if (sort_nr) | 312 if (sort_nr) |
311 result = l1.start_col_nr - l2.start_col_nr; | 313 result = l1.start_col_nr - l2.start_col_nr; |
312 else | 314 else |
313 { | 315 { |
314 /* We need to copy one line into "sortbuf1", because there is no guarantee | 316 /* We need to copy one line into "sortbuf1", because there is no |
315 * that the first pointer becomes invalid when obtaining the second one. */ | 317 * guarantee that the first pointer becomes invalid when obtaining the |
316 STRNCPY(sortbuf1, ml_get(l1.lnum) + l1.start_col_nr, l1.end_col_nr - l1.start_col_nr + 1); | 318 * second one. */ |
319 STRNCPY(sortbuf1, ml_get(l1.lnum) + l1.start_col_nr, | |
320 l1.end_col_nr - l1.start_col_nr + 1); | |
317 sortbuf1[l1.end_col_nr - l1.start_col_nr] = 0; | 321 sortbuf1[l1.end_col_nr - l1.start_col_nr] = 0; |
318 STRNCPY(sortbuf2, ml_get(l2.lnum) + l2.start_col_nr, l2.end_col_nr - l2.start_col_nr + 1); | 322 STRNCPY(sortbuf2, ml_get(l2.lnum) + l2.start_col_nr, |
323 l2.end_col_nr - l2.start_col_nr + 1); | |
319 sortbuf2[l2.end_col_nr - l2.start_col_nr] = 0; | 324 sortbuf2[l2.end_col_nr - l2.start_col_nr] = 0; |
320 | 325 |
321 result = sort_ic ? STRICMP(sortbuf1, sortbuf2) : STRCMP(sortbuf1, sortbuf2); | 326 result = sort_ic ? STRICMP(sortbuf1, sortbuf2) |
322 } | 327 : STRCMP(sortbuf1, sortbuf2); |
323 /* If the two lines have the same value, preserve the original line order */ | 328 } |
329 | |
330 /* If two lines have the same value, preserve the original line order. */ | |
324 if (result == 0) | 331 if (result == 0) |
325 return (int) (l1.lnum - l2.lnum); | 332 return (int)(l1.lnum - l2.lnum); |
326 else | 333 return result; |
327 return result; | |
328 } | 334 } |
329 | 335 |
330 /* | 336 /* |
331 * ":sort". | 337 * ":sort". |
332 */ | 338 */ |