MCPcopy Create free account
hub / github.com/coreutils/coreutils / char_to_clump

Function char_to_clump

src/pr.c:2646–2738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2644 number of characters is 1.) */
2645
2646static int
2647char_to_clump (char c)
2648{
2649 unsigned char uc = c;
2650 char *s = clump_buff;
2651 char esc_buff[4];
2652 int width;
2653 int chars;
2654 int chars_per_c = 8;
2655
2656 if (c == input_tab_char)
2657 chars_per_c = chars_per_input_tab;
2658
2659 if (c == input_tab_char || c == '\t')
2660 {
2661 width = TAB_WIDTH (chars_per_c, input_position);
2662
2663 if (untabify_input)
2664 {
2665 for (int i = width; i; --i)
2666 *s++ = ' ';
2667 chars = width;
2668 }
2669 else
2670 {
2671 *s = c;
2672 chars = 1;
2673 }
2674
2675 }
2676 else if (! isprint (uc))
2677 {
2678 if (use_esc_sequence)
2679 {
2680 width = 4;
2681 chars = 4;
2682 *s++ = '\\';
2683 sprintf (esc_buff, "%03o", uc);
2684 for (int i = 0; i <= 2; ++i)
2685 *s++ = esc_buff[i];
2686 }
2687 else if (use_cntrl_prefix)
2688 {
2689 if (uc < 0200)
2690 {
2691 width = 2;
2692 chars = 2;
2693 *s++ = '^';
2694 *s = c ^ 0100;
2695 }
2696 else
2697 {
2698 width = 4;
2699 chars = 4;
2700 *s++ = '\\';
2701 sprintf (esc_buff, "%03o", uc);
2702 for (int i = 0; i <= 2; ++i)
2703 *s++ = esc_buff[i];

Callers 1

read_lineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected