Skip to content

Instantly share code, notes, and snippets.

@nikic
Created April 9, 2012 13:47
Show Gist options
  • Save nikic/2343520 to your computer and use it in GitHub Desktop.
Save nikic/2343520 to your computer and use it in GitHub Desktop.
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index f26e5d8..e52fb3f 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -468,21 +468,26 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
PRINTF_DEBUG(("sprintf: looking for modifiers\n"
"sprintf: now looking at '%c', inpos=%d\n",
format[inpos], inpos));
- for (;; inpos++) {
- if (format[inpos] == ' ' || format[inpos] == '0') {
- padding = format[inpos];
- } else if (format[inpos] == '-') {
- alignment = ALIGN_LEFT;
- /* space padding, the default */
- } else if (format[inpos] == '+') {
- always_sign = 1;
- } else if (format[inpos] == '\'') {
- padding = format[++inpos];
- } else {
- PRINTF_DEBUG(("sprintf: end of modifiers\n"));
- break;
- }
+
+ if (format[inpos] == '+') {
+ always_sign = 1;
+ inpos++;
+ }
+
+ if (format[inpos] == ' ' || format[inpos] == '0') {
+ padding = format[inpos];
+ inpos++;
+ } else if (format[inpos] == '\'') {
+ padding = format[++inpos];
+ inpos++;
+ }
+
+ if (format[inpos] == '-') {
+ alignment = ALIGN_LEFT;
+ inpos++;
}
+
+ PRINTF_DEBUG(("sprintf: end of modifiers\n"));
PRINTF_DEBUG(("sprintf: padding='%c'\n", padding));
PRINTF_DEBUG(("sprintf: alignment=%s\n",
(alignment == ALIGN_LEFT) ? "left" : "right"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment