Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (6 years ago)
Author:
bruno
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/coreutils/printf.c

    r2725 r3232  
    3737*/
    3838
    39 //   19990508 Busy Boxed! Dave Cinege
     39/* 19990508 Busy Boxed! Dave Cinege */
     40
     41//usage:#define printf_trivial_usage
     42//usage:       "FORMAT [ARG]..."
     43//usage:#define printf_full_usage "\n\n"
     44//usage:       "Format and print ARG(s) according to FORMAT (a-la C printf)"
     45//usage:
     46//usage:#define printf_example_usage
     47//usage:       "$ printf \"Val=%d\\n\" 5\n"
     48//usage:       "Val=5\n"
    4049
    4150#include "libbb.h"
     
    123132}
    124133
     134/* Handles %b */
    125135static void print_esc_string(const char *str)
    126136{
     
    128138    while ((c = *str) != '\0') {
    129139        str++;
    130         if (c == '\\')
    131             c = bb_process_escape_sequence(&str);
     140        if (c == '\\') {
     141            /* %b also accepts 4-digit octals of the form \0### */
     142            if (*str == '0') {
     143                if ((unsigned char)(str[1] - '0') < 8) {
     144                    /* 2nd char is 0..7: skip leading '0' */
     145                    str++;
     146                }
     147            }
     148            {
     149                /* optimization: don't force arg to be on-stack,
     150                 * use another variable for that. */
     151                const char *z = str;
     152                c = bb_process_escape_sequence(&z);
     153                str = z;
     154            }
     155        }
    132156        putchar(c);
    133157    }
Note: See TracChangeset for help on using the changeset viewer.