~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to cmd-line-utils/libedit/emacs.c

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $      */
 
1
/*      $NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $      */
2
2
 
3
3
/*-
4
4
 * Copyright (c) 1992, 1993
51
51
 */
52
52
protected el_action_t
53
53
/*ARGSUSED*/
54
 
em_delete_or_list(EditLine *el, int c)
 
54
em_delete_or_list(EditLine *el, Int c)
55
55
{
56
56
 
57
57
        if (el->el_line.cursor == el->el_line.lastchar) {
58
58
                                        /* if I'm at the end */
59
59
                if (el->el_line.cursor == el->el_line.buffer) {
60
60
                                        /* and the beginning */
61
 
                        term_writec(el, c);     /* then do an EOF */
62
 
                        return (CC_EOF);
 
61
                        terminal_writec(el, c); /* then do an EOF */
 
62
                        return CC_EOF;
63
63
                } else {
64
64
                        /*
65
65
                         * Here we could list completions, but it is an
66
66
                         * error right now
67
67
                         */
68
 
                        term_beep(el);
69
 
                        return (CC_ERROR);
 
68
                        terminal_beep(el);
 
69
                        return CC_ERROR;
70
70
                }
71
71
        } else {
72
72
                if (el->el_state.doingarg)
76
76
                if (el->el_line.cursor > el->el_line.lastchar)
77
77
                        el->el_line.cursor = el->el_line.lastchar;
78
78
                                /* bounds check */
79
 
                return (CC_REFRESH);
 
79
                return CC_REFRESH;
80
80
        }
81
81
}
82
82
 
87
87
 */
88
88
protected el_action_t
89
89
/*ARGSUSED*/
90
 
em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
 
90
em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
91
91
{
92
 
        char *cp, *p, *kp;
 
92
        Char *cp, *p, *kp;
93
93
 
94
94
        if (el->el_line.cursor == el->el_line.lastchar)
95
 
                return (CC_ERROR);
 
95
                return CC_ERROR;
96
96
 
97
97
        cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
98
98
            el->el_state.argument, ce__isword);
102
102
                *kp++ = *p;
103
103
        el->el_chared.c_kill.last = kp;
104
104
 
105
 
        c_delafter(el, cp - el->el_line.cursor);        /* delete after dot */
 
105
        c_delafter(el, (int)(cp - el->el_line.cursor)); /* delete after dot */
106
106
        if (el->el_line.cursor > el->el_line.lastchar)
107
107
                el->el_line.cursor = el->el_line.lastchar;
108
108
                                /* bounds check */
109
 
        return (CC_REFRESH);
 
109
        return CC_REFRESH;
110
110
}
111
111
 
112
112
 
116
116
 */
117
117
protected el_action_t
118
118
/*ARGSUSED*/
119
 
em_yank(EditLine *el, int c __attribute__((__unused__)))
 
119
em_yank(EditLine *el, Int c __attribute__((__unused__)))
120
120
{
121
 
        char *kp, *cp;
 
121
        Char *kp, *cp;
122
122
 
123
123
        if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
124
 
                return (CC_NORM);
 
124
                return CC_NORM;
125
125
 
126
126
        if (el->el_line.lastchar +
127
127
            (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
128
128
            el->el_line.limit)
129
 
                return (CC_ERROR);
 
129
                return CC_ERROR;
130
130
 
131
131
        el->el_chared.c_kill.mark = el->el_line.cursor;
132
132
        cp = el->el_line.cursor;
133
133
 
134
134
        /* open the space, */
135
 
        c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
 
135
        c_insert(el,
 
136
            (int)(el->el_chared.c_kill.last - el->el_chared.c_kill.buf));
136
137
        /* copy the chars */
137
138
        for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
138
139
                *cp++ = *kp;
141
142
        if (el->el_state.argument == 1)
142
143
                el->el_line.cursor = cp;
143
144
 
144
 
        return (CC_REFRESH);
 
145
        return CC_REFRESH;
145
146
}
146
147
 
147
148
 
151
152
 */
152
153
protected el_action_t
153
154
/*ARGSUSED*/
154
 
em_kill_line(EditLine *el, int c __attribute__((__unused__)))
 
155
em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
155
156
{
156
 
        char *kp, *cp;
 
157
        Char *kp, *cp;
157
158
 
158
159
        cp = el->el_line.buffer;
159
160
        kp = el->el_chared.c_kill.buf;
163
164
                                /* zap! -- delete all of it */
164
165
        el->el_line.lastchar = el->el_line.buffer;
165
166
        el->el_line.cursor = el->el_line.buffer;
166
 
        return (CC_REFRESH);
 
167
        return CC_REFRESH;
167
168
}
168
169
 
169
170
 
173
174
 */
174
175
protected el_action_t
175
176
/*ARGSUSED*/
176
 
em_kill_region(EditLine *el, int c __attribute__((__unused__)))
 
177
em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
177
178
{
178
 
        char *kp, *cp;
 
179
        Char *kp, *cp;
179
180
 
180
181
        if (!el->el_chared.c_kill.mark)
181
 
                return (CC_ERROR);
 
182
                return CC_ERROR;
182
183
 
183
184
        if (el->el_chared.c_kill.mark > el->el_line.cursor) {
184
185
                cp = el->el_line.cursor;
186
187
                while (cp < el->el_chared.c_kill.mark)
187
188
                        *kp++ = *cp++;  /* copy it */
188
189
                el->el_chared.c_kill.last = kp;
189
 
                c_delafter(el, cp - el->el_line.cursor);
 
190
                c_delafter(el, (int)(cp - el->el_line.cursor));
190
191
        } else {                /* mark is before cursor */
191
192
                cp = el->el_chared.c_kill.mark;
192
193
                kp = el->el_chared.c_kill.buf;
193
194
                while (cp < el->el_line.cursor)
194
195
                        *kp++ = *cp++;  /* copy it */
195
196
                el->el_chared.c_kill.last = kp;
196
 
                c_delbefore(el, cp - el->el_chared.c_kill.mark);
 
197
                c_delbefore(el, (int)(cp - el->el_chared.c_kill.mark));
197
198
                el->el_line.cursor = el->el_chared.c_kill.mark;
198
199
        }
199
 
        return (CC_REFRESH);
 
200
        return CC_REFRESH;
200
201
}
201
202
 
202
203
 
206
207
 */
207
208
protected el_action_t
208
209
/*ARGSUSED*/
209
 
em_copy_region(EditLine *el, int c __attribute__((__unused__)))
 
210
em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
210
211
{
211
 
        char *kp, *cp;
 
212
        Char *kp, *cp;
212
213
 
213
214
        if (!el->el_chared.c_kill.mark)
214
 
                return (CC_ERROR);
 
215
                return CC_ERROR;
215
216
 
216
217
        if (el->el_chared.c_kill.mark > el->el_line.cursor) {
217
218
                cp = el->el_line.cursor;
226
227
                        *kp++ = *cp++;  /* copy it */
227
228
                el->el_chared.c_kill.last = kp;
228
229
        }
229
 
        return (CC_NORM);
 
230
        return CC_NORM;
230
231
}
231
232
 
232
233
 
235
236
 *      Gosling emacs transpose chars [^T]
236
237
 */
237
238
protected el_action_t
238
 
em_gosmacs_transpose(EditLine *el, int c)
 
239
em_gosmacs_transpose(EditLine *el, Int c)
239
240
{
240
241
 
241
242
        if (el->el_line.cursor > &el->el_line.buffer[1]) {
243
244
                c = el->el_line.cursor[-2];
244
245
                el->el_line.cursor[-2] = el->el_line.cursor[-1];
245
246
                el->el_line.cursor[-1] = c;
246
 
                return (CC_REFRESH);
 
247
                return CC_REFRESH;
247
248
        } else
248
 
                return (CC_ERROR);
 
249
                return CC_ERROR;
249
250
}
250
251
 
251
252
 
255
256
 */
256
257
protected el_action_t
257
258
/*ARGSUSED*/
258
 
em_next_word(EditLine *el, int c __attribute__((__unused__)))
 
259
em_next_word(EditLine *el, Int c __attribute__((__unused__)))
259
260
{
260
261
        if (el->el_line.cursor == el->el_line.lastchar)
261
 
                return (CC_ERROR);
 
262
                return CC_ERROR;
262
263
 
263
264
        el->el_line.cursor = c__next_word(el->el_line.cursor,
264
265
            el->el_line.lastchar,
268
269
        if (el->el_map.type == MAP_VI)
269
270
                if (el->el_chared.c_vcmd.action != NOP) {
270
271
                        cv_delfini(el);
271
 
                        return (CC_REFRESH);
 
272
                        return CC_REFRESH;
272
273
                }
273
 
        return (CC_CURSOR);
 
274
        return CC_CURSOR;
274
275
}
275
276
 
276
277
 
280
281
 */
281
282
protected el_action_t
282
283
/*ARGSUSED*/
283
 
em_upper_case(EditLine *el, int c __attribute__((__unused__)))
 
284
em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
284
285
{
285
 
        char *cp, *ep;
 
286
        Char *cp, *ep;
286
287
 
287
288
        ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
288
289
            el->el_state.argument, ce__isword);
289
290
 
290
291
        for (cp = el->el_line.cursor; cp < ep; cp++)
291
 
                if (islower((unsigned char)*cp))
292
 
                        *cp = toupper((unsigned char)*cp);
 
292
                if (Islower(*cp))
 
293
                        *cp = Toupper(*cp);
293
294
 
294
295
        el->el_line.cursor = ep;
295
296
        if (el->el_line.cursor > el->el_line.lastchar)
296
297
                el->el_line.cursor = el->el_line.lastchar;
297
 
        return (CC_REFRESH);
 
298
        return CC_REFRESH;
298
299
}
299
300
 
300
301
 
304
305
 */
305
306
protected el_action_t
306
307
/*ARGSUSED*/
307
 
em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
 
308
em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
308
309
{
309
 
        char *cp, *ep;
 
310
        Char *cp, *ep;
310
311
 
311
312
        ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
312
313
            el->el_state.argument, ce__isword);
313
314
 
314
315
        for (cp = el->el_line.cursor; cp < ep; cp++) {
315
 
                if (isalpha((unsigned char)*cp)) {
316
 
                        if (islower((unsigned char)*cp))
317
 
                                *cp = toupper((unsigned char)*cp);
 
316
                if (Isalpha(*cp)) {
 
317
                        if (Islower(*cp))
 
318
                                *cp = Toupper(*cp);
318
319
                        cp++;
319
320
                        break;
320
321
                }
321
322
        }
322
323
        for (; cp < ep; cp++)
323
 
                if (isupper((unsigned char)*cp))
324
 
                        *cp = tolower((unsigned char)*cp);
 
324
                if (Isupper(*cp))
 
325
                        *cp = Tolower(*cp);
325
326
 
326
327
        el->el_line.cursor = ep;
327
328
        if (el->el_line.cursor > el->el_line.lastchar)
328
329
                el->el_line.cursor = el->el_line.lastchar;
329
 
        return (CC_REFRESH);
 
330
        return CC_REFRESH;
330
331
}
331
332
 
332
333
 
336
337
 */
337
338
protected el_action_t
338
339
/*ARGSUSED*/
339
 
em_lower_case(EditLine *el, int c __attribute__((__unused__)))
 
340
em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
340
341
{
341
 
        char *cp, *ep;
 
342
        Char *cp, *ep;
342
343
 
343
344
        ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
344
345
            el->el_state.argument, ce__isword);
345
346
 
346
347
        for (cp = el->el_line.cursor; cp < ep; cp++)
347
 
                if (isupper((unsigned char)*cp))
348
 
                        *cp = tolower((unsigned char)*cp);
 
348
                if (Isupper(*cp))
 
349
                        *cp = Tolower(*cp);
349
350
 
350
351
        el->el_line.cursor = ep;
351
352
        if (el->el_line.cursor > el->el_line.lastchar)
352
353
                el->el_line.cursor = el->el_line.lastchar;
353
 
        return (CC_REFRESH);
 
354
        return CC_REFRESH;
354
355
}
355
356
 
356
357
 
360
361
 */
361
362
protected el_action_t
362
363
/*ARGSUSED*/
363
 
em_set_mark(EditLine *el, int c __attribute__((__unused__)))
 
364
em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
364
365
{
365
366
 
366
367
        el->el_chared.c_kill.mark = el->el_line.cursor;
367
 
        return (CC_NORM);
 
368
        return CC_NORM;
368
369
}
369
370
 
370
371
 
374
375
 */
375
376
protected el_action_t
376
377
/*ARGSUSED*/
377
 
em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
 
378
em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
378
379
{
379
 
        char *cp;
 
380
        Char *cp;
380
381
 
381
382
        cp = el->el_line.cursor;
382
383
        el->el_line.cursor = el->el_chared.c_kill.mark;
383
384
        el->el_chared.c_kill.mark = cp;
384
 
        return (CC_CURSOR);
 
385
        return CC_CURSOR;
385
386
}
386
387
 
387
388
 
391
392
 */
392
393
protected el_action_t
393
394
/*ARGSUSED*/
394
 
em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
 
395
em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
395
396
{                               /* multiply current argument by 4 */
396
397
 
397
398
        if (el->el_state.argument > 1000000)
398
 
                return (CC_ERROR);
 
399
                return CC_ERROR;
399
400
        el->el_state.doingarg = 1;
400
401
        el->el_state.argument *= 4;
401
 
        return (CC_ARGHACK);
 
402
        return CC_ARGHACK;
402
403
}
403
404
 
404
405
 
408
409
 */
409
410
protected el_action_t
410
411
/*ARGSUSED*/
411
 
em_meta_next(EditLine *el, int c __attribute__((__unused__)))
 
412
em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
412
413
{
413
414
 
414
415
        el->el_state.metanext = 1;
415
 
        return (CC_ARGHACK);
 
416
        return CC_ARGHACK;
416
417
}
417
418
 
418
419
 
421
422
 */
422
423
protected el_action_t
423
424
/*ARGSUSED*/
424
 
em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
 
425
em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
425
426
{
426
427
 
427
428
        el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
428
429
            MODE_REPLACE : MODE_INSERT;
429
 
        return (CC_NORM);
 
430
        return CC_NORM;
430
431
}
431
432
 
432
433
 
435
436
 */
436
437
protected el_action_t
437
438
/*ARGSUSED*/
438
 
em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
 
439
em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
439
440
{
440
 
        char *cp, *oldc, *dp;
 
441
        Char *cp, *oldc, *dp;
441
442
 
442
443
        if (el->el_line.cursor == el->el_line.buffer)
443
 
                return (CC_ERROR);
 
444
                return CC_ERROR;
444
445
 
445
446
        oldc = el->el_line.cursor;
446
447
        /* does a bounds check */
447
448
        cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
448
449
            el->el_state.argument, ce__isword);
449
450
 
450
 
        c_insert(el, oldc - cp);
 
451
        c_insert(el, (int)(oldc - cp));
451
452
        for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
452
453
                *dp++ = *cp;
453
454
 
454
455
        el->el_line.cursor = dp;/* put cursor at end */
455
456
 
456
 
        return (CC_REFRESH);
 
457
        return CC_REFRESH;
457
458
}
458
459
 
459
460
 
462
463
 */
463
464
protected el_action_t
464
465
/*ARGSUSED*/
465
 
em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
 
466
em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
466
467
{
467
468
 
468
469
        el->el_search.patlen = 0;
469
 
        return (ce_inc_search(el, ED_SEARCH_NEXT_HISTORY));
 
470
        return ce_inc_search(el, ED_SEARCH_NEXT_HISTORY);
470
471
}
471
472
 
472
473
 
475
476
 */
476
477
protected el_action_t
477
478
/*ARGSUSED*/
478
 
em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
 
479
em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
479
480
{
480
481
 
481
482
        el->el_search.patlen = 0;
482
 
        return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
 
483
        return ce_inc_search(el, ED_SEARCH_PREV_HISTORY);
483
484
}
484
485
 
485
486
 
489
490
 */
490
491
protected el_action_t
491
492
/*ARGSUSED*/
492
 
em_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
 
493
em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
493
494
{
494
495
 
495
496
        if (el->el_line.cursor <= el->el_line.buffer)
496
 
                return (CC_ERROR);
 
497
                return CC_ERROR;
497
498
 
498
499
        if (el->el_state.doingarg)
499
500
                c_delbefore(el, el->el_state.argument);
502
503
        el->el_line.cursor -= el->el_state.argument;
503
504
        if (el->el_line.cursor < el->el_line.buffer)
504
505
                el->el_line.cursor = el->el_line.buffer;
505
 
        return (CC_REFRESH);
 
506
        return CC_REFRESH;
506
507
}