~ubuntu-branches/debian/wheezy/tweak/wheezy

« back to all changes in this revision

Viewing changes to actions.c

  • Committer: Package Import Robot
  • Author(s): Daniel Kahn Gillmor
  • Date: 2012-03-04 19:37:53 UTC
  • Revision ID: package-import@ubuntu.com-20120304193753-jnid7ekl6wkag63d
Tags: 3.01-8
* debian/control: bump Standards-Version to 3.9.3 (no changes needed),
  change Vcs- fields.
* debian/rules: minimize, move to dh 8
* convert source format to '3.0 (quilt)' (dropping dpatch build-dep)
* drop halibut build-dep in favor of shipping upstream's man page and
  documentation directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
    if (!backed_up) {
140
140
        if (!backup_file()) {
141
141
            display_beep();
142
 
            strcpy (message, "Unable to back up file!");
 
142
            strncpy (message, "Unable to back up file!", sizeof(message) - 1);
143
143
            return;
144
144
        }
145
145
        backed_up = TRUE;
146
146
    }
147
147
    if (!save_file()) {
148
148
        display_beep();
149
 
        strcpy (message, "Unable to save file!");
 
149
        strncpy (message, "Unable to save file!", sizeof(message) - 1);
150
150
        return;
151
151
    }
152
152
    modified = FALSE;
292
292
static void act_togins(void) {
293
293
    if (look_mode || fix_mode) {
294
294
        display_beep();
295
 
        sprintf(message, "Can't engage Insert mode when in %s mode",
 
295
        snprintf(message, sizeof(message), "Can't engage Insert mode when in %s mode",
296
296
                (look_mode ? "LOOK" : "FIX"));
297
297
        insert_mode = FALSE;           /* safety! */
298
298
    } else
312
312
 
313
313
    if (look_mode) {
314
314
        display_beep();
315
 
        strcpy (message, "Can't modify file in LOOK mode");
 
315
        strncpy (message, "Can't modify file in LOOK mode", sizeof(message - 1));
316
316
        return;
317
317
    }
318
318
 
325
325
            last_char -= 'a'-10;
326
326
        else {
327
327
            display_beep();
328
 
            strcpy(message, "Not a valid character when in hex editing mode");
 
328
            strncpy(message, "Not a valid character when in hex editing mode", sizeof(message) - 1);
329
329
            return;
330
330
        }
331
331
    }
332
332
 
333
333
    if ( (!insert || edit_type == 2) && cur_pos == file_size) {
334
334
        display_beep();
335
 
        strcpy(message, "End of file reached");
 
335
        strncpy(message, "End of file reached", sizeof(message) - 1);
336
336
        return;
337
337
    }
338
338
 
365
365
        modified = TRUE;
366
366
    } else {
367
367
        display_beep();
368
 
        strcpy(message, "End of file reached");
 
368
        strncpy(message, "End of file reached", sizeof(message) - 1);
369
369
    }
370
370
    act_right();
371
371
}
373
373
static void act_delete(void) {
374
374
    if (!insert_mode || (edit_type!=2 && cur_pos==0)) {
375
375
        display_beep();
376
 
        strcpy (message, "Can't delete while not in Insert mode");
 
376
        strncpy (message, "Can't delete while not in Insert mode", sizeof(message) - 1);
377
377
    } else if (cur_pos > 0 || edit_type == 2) {
378
378
        act_left();
379
379
        buf_delete (filedata, 1, cur_pos);
386
386
static void act_delch(void) {
387
387
    if (!insert_mode) {
388
388
        display_beep();
389
 
        strcpy (message, "Can't delete while not in Insert mode");
 
389
        strncpy (message, "Can't delete while not in Insert mode", sizeof(message) - 1);
390
390
    } else if (cur_pos < file_size) {
391
391
        buf_delete (filedata, 1, cur_pos);
392
392
        file_size--;
398
398
static void act_mark (void) {
399
399
    if (look_mode) {
400
400
        display_beep();
401
 
        strcpy (message, "Can't cut or paste in LOOK mode");
 
401
        strncpy (message, "Can't cut or paste in LOOK mode", sizeof(message) - 1);
402
402
        marking = FALSE;               /* safety */
403
403
        return;
404
404
    }
411
411
 
412
412
    if (!marking || mark_point==cur_pos) {
413
413
        display_beep();
414
 
        strcpy (message, "Set mark first");
 
414
        strncpy (message, "Set mark first", sizeof(message) - 1);
415
415
        return;
416
416
    }
417
417
    if (!insert_mode) {
418
418
        display_beep();
419
 
        strcpy (message, "Can't cut while not in Insert mode");
 
419
        strncpy (message, "Can't cut while not in Insert mode", sizeof(message) - 1);
420
420
        return;
421
421
    }
422
422
    marktop = cur_pos;
444
444
 
445
445
    if (!marking) {
446
446
        display_beep();
447
 
        strcpy (message, "Set mark first");
 
447
        strncpy (message, "Set mark first", sizeof(message) - 1);
448
448
        return;
449
449
    }
450
450
    marktop = cur_pos;
466
466
    if (!insert_mode) {
467
467
        if (cur_pos + cutsize > file_size) {
468
468
            display_beep();
469
 
            strcpy (message, "Too close to end of file to paste");
 
469
            strncpy (message, "Too close to end of file to paste", sizeof(message) - 1);
470
470
            return;
471
471
        }
472
472
        buf_delete (filedata, cutsize, cur_pos);
500
500
    position = parse_num (buffer, &error);
501
501
    if (error) {
502
502
        display_beep();
503
 
        strcpy (message, "Unable to parse position value");
 
503
        strncpy (message, "Unable to parse position value", sizeof(message) - 1);
504
504
        return;
505
505
    }
506
506
 
507
507
    if (position < 0 || position > file_size) {
508
508
        display_beep();
509
 
        strcpy (message, "Position is outside bounds of file");
 
509
        strncpy (message, "Position is outside bounds of file", sizeof(message) - 1);
510
510
        return;
511
511
    }
512
512
 
537
537
    if (!get_str(last_search ? withdef : withoutdef, buffer, TRUE))
538
538
        return 0;                      /* user break */
539
539
    if (!last_search && !*buffer) {
540
 
        strcpy (message, "Search aborted.");
 
540
        strncpy (message, "Search aborted.", sizeof(message) - 1);
541
541
        return 0;
542
542
    }
543
543
 
547
547
        len = parse_quoted (buffer);
548
548
        if (len == -1) {
549
549
            display_beep();
550
 
            strcpy (message, "Invalid escape sequence in search string");
 
550
            strncpy (message, "Invalid escape sequence in search string", sizeof(message) - 1);
551
551
            return 0;
552
552
        }
553
553
        if (last_search)
597
597
            }
598
598
        }
599
599
    }
600
 
    strcpy (message, "Not found.");
 
600
    strncpy (message, "Not found.", sizeof(message) - 1);
601
601
}
602
602
 
603
603
static void act_search_backwards (void) {
643
643
            }
644
644
        }
645
645
    }
646
 
    strcpy (message, "Not found.");
 
646
    strncpy (message, "Not found.", sizeof(message) - 1);
647
647
}
648
648
 
649
649
static void act_recentre (void) {
660
660
    fileoffset_t new_top;
661
661
    int error;
662
662
 
663
 
    sprintf (prompt, "Enter screen width in bytes (now %"OFF"d): ", width);
 
663
    snprintf (prompt, sizeof(prompt), "Enter screen width in bytes (now %"OFF"d): ", width);
664
664
    if (!get_str (prompt, buffer, FALSE))
665
665
        return;
666
666
    w = parse_num (buffer, &error);
667
667
    if (error) {
668
668
        display_beep();
669
 
        strcpy (message, "Unable to parse width value");
 
669
        strncpy (message, "Unable to parse width value", sizeof(message) - 1);
670
670
        return;
671
671
    }
672
672
    if (w > 0) {
686
686
    fileoffset_t new_top;
687
687
    int error;
688
688
 
689
 
    sprintf (prompt, "Enter start-of-file offset in bytes (now %"OFF"d): ",
 
689
    snprintf (prompt, sizeof(prompt), "Enter start-of-file offset in bytes (now %"OFF"d): ",
690
690
             realoffset);
691
691
    if (!get_str (prompt, buffer, FALSE))
692
692
        return;
693
693
    o = parse_num (buffer, &error);
694
694
    if (error) {
695
695
        display_beep();
696
 
        strcpy (message, "Unable to parse offset value");
 
696
        strncpy (message, "Unable to parse offset value", sizeof(message) - 1);
697
697
        return;
698
698
    }
699
699
    if (o >= 0) {