1/* 2 * Copyright (c) 2002-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 55 unchanged lines hidden (view full) --- 64{ 65 fmt.clear(); 66 67 size_t len; 68 69 while (*ptr) { 70 switch (*ptr) { 71 case '%': |
72 if (ptr[1] != '%') { 73 process_flag(); 74 return; 75 } |
76 stream.put('%'); 77 ptr += 2; 78 break; 79 80 case '\n': 81 stream << endl; 82 ++ptr; 83 break; --- 5 unchanged lines hidden (view full) --- 89 90 default: 91 len = strcspn(ptr, "%\n\r\0"); 92 stream.write(ptr, len); 93 ptr += len; 94 break; 95 } 96 } |
97} |
98 |
99void 100Print::process_flag() 101{ |
102 bool done = false; 103 bool end_number = false; 104 bool have_precision = false; 105 int number = 0; 106 107 stream.fill(' '); 108 stream.flags((ios::fmtflags)0); 109 --- 135 unchanged lines hidden (view full) --- 245 if (have_precision) 246 fmt.precision = number; 247 else 248 fmt.width = number; 249 250 end_number = false; 251 number = 0; 252 } |
253 |
254 if (done) { 255 if ((fmt.format == Format::integer) && have_precision) { 256 // specified a . but not a float, set width 257 fmt.width = fmt.precision; 258 // precision requries digits for width, must fill with 0 259 fmt.fill_zero = true; 260 } else if ((fmt.format == Format::floating) && !have_precision && 261 fmt.fill_zero) { 262 // ambiguous case, matching printf 263 fmt.precision = fmt.width; 264 } 265 } 266 } // end while 267 |
268 ++ptr; 269} 270 271void 272Print::end_args() 273{ 274 size_t len; 275 --- 34 unchanged lines hidden --- |