#define FT_LS_CFIND 15 /* set "str" to context_find(text) */
#define FT_LS_DECODECOMP 16 /* set "str" to decoded component text */
#define FT_LS_DECODE 17 /* decode "str" as RFC-2047 header */
-#define FT_LS_TRIM 18 /* trim trailing white space from "str" */
+#define FT_LS_TRIM 18 /* trim white space from "str" */
#define FT_LV_COMP 19 /* set "value" to comp (as dec. num) */
#define FT_LV_COMPFLAG 20 /* set "value" to comp flag word */
#define FT_LV_LIT 21 /* set "value" to literal num */
component and print it
unquote expr string remove RFC-2822 quotes from \fIstr\fR
unmailto expr string remove `mailto:' and < > from \fIstr\fR
-trim expr trim trailing white-space from \fIstr\fR
+trim expr trim white-space from \fIstr\fR
putstr expr print \fIstr\fR
putstrf expr print \fIstr\fR in a fixed width
putnum expr print \fInum\fR
static int match(char *, char *);
static char *get_x400_friendly(char *, char *, int);
static int get_x400_comp(char *, char *, char *, int);
+static char *fmt_trim(char *, int);
/*
return 1;
}
+static char *
+fmt_trim(char *str, int width)
+{
+ char *xp;
+ int ljust, i;
+ char buffer[BUFSIZ];
+
+ strncpy(buffer, str, sizeof(buffer));
+ buffer[sizeof(buffer)-1] = '\0';
+ str = buffer;
+ while (isspace(*str)) {
+ str++;
+ }
+ ljust = 0;
+ if ((i = width) < 0) {
+ i = -i;
+ ljust++;
+ }
+
+ if (!ljust && i > 0 && (int)strlen(str) > i) {
+ str[i] = '\0';
+ }
+ xp = str;
+ xp += strlen(str) - 1;
+ while (xp > str && isspace(*xp)) {
+ *xp-- = '\0';
+ }
+ if (ljust && i > 0 && (int)strlen(str) > i) {
+ str += strlen(str) - i;
+ }
+ return str;
+}
+
struct format *
fmt_scan(struct format *format, char *scanl, int width, int *dat)
{
case FT_LS_TRIM:
if (str) {
- unsigned char *xp;
-
- strncpy(buffer, str, sizeof(buffer));
- buffer[sizeof(buffer)-1] = '\0';
- str = buffer;
- while (isspace(*str))
- str++;
- ljust = 0;
- if ((i = fmt->f_width) < 0) {
- i = -i;
- ljust++;
- }
-
- if (!ljust && i > 0 && (int)strlen(str) > i)
- str[i] = '\0';
- xp = str;
- xp += strlen(str) - 1;
- while (xp > str && isspace(*xp))
- *xp-- = '\0';
- if (ljust && i > 0 && (int)strlen(str) > i)
- str += strlen(str) - i;
+ str = fmt_trim(str, fmt->f_width);
}
break;