[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH 4/7] Separate out the handling of \c.
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH 4/7] Separate out the handling of \c. |
Date: |
Wed, 29 Jun 2011 10:16:53 +0100 |
* find/print.c (insert_fprintf): Deal with \c as a special case.
---
ChangeLog | 3 +++
find/print.c | 27 ++++++++++++++++-----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bbec435..bd4b7e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-06-25 James Youngman <address@hidden>
+ Separate out the handling of \c.
+ * find/print.c (insert_fprintf): Deal with \c as a special case.
+
Remove some redundant continue statements.
* find/print.c (insert_fprintf): Remove a pair of redundant
'continue' statements.
diff --git a/find/print.c b/find/print.c
index 7270b94..0d53bac 100644
--- a/find/print.c
+++ b/find/print.c
@@ -239,13 +239,22 @@ insert_fprintf (struct format_val *vec,
for (fmt_editpos = segstart; *fmt_editpos; fmt_editpos++)
{
- if (*fmt_editpos == '\\')
+ if (fmt_editpos[0] == '\\' && fmt_editpos[1] == 'c')
{
- fmt_inpos = fmt_editpos + 1;
- if (*fmt_inpos >= '0' && *fmt_inpos <= '7')
+ make_segment (segmentp, segstart, fmt_editpos - segstart,
+ KIND_STOP, 0, 0,
+ our_pred);
+ if (our_pred->need_stat && (our_pred->p_cost < NeedsStatInfo))
+ our_pred->p_cost = NeedsStatInfo;
+ return true;
+ }
+ else if (*fmt_editpos == '\\')
+ {
+ if (fmt_editpos[1] >= '0' && fmt_editpos[1] <= '7')
{
register int n, i;
+ fmt_inpos = fmt_editpos + 1;
for (i = n = 0; i < 3 && (*fmt_inpos >= '0' && *fmt_inpos <= '7');
i++, fmt_inpos++)
n = 8 * n + *fmt_inpos - '0';
@@ -254,21 +263,15 @@ insert_fprintf (struct format_val *vec,
}
else
{
+ fmt_inpos = fmt_editpos + 1;
switch (*fmt_inpos)
{
case 'a':
- *fmt_editpos = 7;
+ *fmt_editpos = '\a';
break;
case 'b':
*fmt_editpos = '\b';
break;
- case 'c':
- make_segment (segmentp, segstart, fmt_editpos - segstart,
- KIND_STOP, 0, 0,
- our_pred);
- if (our_pred->need_stat && (our_pred->p_cost < NeedsStatInfo))
- our_pred->p_cost = NeedsStatInfo;
- return true;
case 'f':
*fmt_editpos = '\f';
break;
@@ -290,6 +293,7 @@ insert_fprintf (struct format_val *vec,
default:
error (0, 0,
_("warning: unrecognized escape `\\%c'"), *fmt_inpos);
+
fmt_editpos++;
continue;
}
@@ -1175,6 +1179,7 @@ do_fprintf (struct format_val *dest,
}
break;
+ case 0:
case '%':
checked_fprintf (dest, segment->text);
break;
--
1.7.2.5
- [Findutils-patches] [PATCH 1/7] Clarify variable naming in insert_fprintf., James Youngman, 2011/06/29
- [Findutils-patches] [PATCH 4/7] Separate out the handling of \c.,
James Youngman <=
- [Findutils-patches] [PATCH 5/7] Factor some of the code out of insert_fprintf., James Youngman, 2011/06/29
- [Findutils-patches] [PATCH 3/7] Remove some redundant continue statements., James Youngman, 2011/06/29
- [Findutils-patches] [PATCH 2/7] Simplify -fprintf %%; handle %% like a regular format specifier., James Youngman, 2011/06/29
- [Findutils-patches] [PATCH 7/7] Fix some constness warnings when dealing with -printf formats., James Youngman, 2011/06/29
- [Findutils-patches] [PATCH 6/7] Refactor insert_fprintf to minimise calls to make_segment., James Youngman, 2011/06/29