altprintf 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 134617d2a0afa2d1fcbcc02b7e83421b625ed740e80a02869d73fd9c32f9bff9
4
- data.tar.gz: 2ff6cc05cd95897746fbdbad9a8d1c7c98ec9ad3430ce6dfcb58de5eea4508ce
3
+ metadata.gz: 1cc830a121e86420a00495ecaf185f65d7e85b78893b178d65878f2568fbf8f1
4
+ data.tar.gz: ec7fbc35f30756832d9b71e8e5a37bf34cc900b725b002497a6eb9cf943a2ee8
5
5
  SHA512:
6
- metadata.gz: 1c6fbb933675cdf58684849b252a61da79241bb86c9da851bc01f9abfeac3e7fa1cfc0211753fd6d0701c68085091c739853a1972d7f3f527ea4a6e89293df3c
7
- data.tar.gz: 2542ed5e8d4417a9858c11b9fab94e61c2582827ee0976c261bc87e3ea8450a4eae9d3fa1e45d2ec955de0067717e88e9739d4e2fe5f8d09e857c4d2005d941e
6
+ metadata.gz: 513567e60633170846a1d51e094ec7e81f1217336de27aa47b2e9e937a59efe1bd5a059695fa86f54e93a0d2f61d7864cf138282db853bee28cac8430fb909fd
7
+ data.tar.gz: 990a2a342a6218e3fea7b2bd8643239cfeaf5d1695c7495ffb80ec7d6ae3003f8e61f515d8e564abf236248096ed84d36f238049c2f1a1ec36e458d1e036b1ba
@@ -0,0 +1,57 @@
1
+ #ifndef ALTPRINTF_H_
2
+ #define ALTPRINTF_H_
3
+ #define ALTPRINTF_VERSION "0.4.0"
4
+ #include <stdlib.h>
5
+
6
+ enum apf_argt {
7
+ apf_argt_mul,
8
+ apf_argt_tern,
9
+ apf_argt_align,
10
+ apf_argt_int,
11
+ apf_argt_char,
12
+ apf_argt_double,
13
+ apf_argt_string,
14
+ apf_argt_raw,
15
+ apf_argt_none,
16
+ apf_argt_end
17
+ };
18
+
19
+ enum apf_align { apf_algn_left, apf_algn_right, apf_algn_center };
20
+
21
+ enum apf_err {
22
+ apf_err_none,
23
+ apf_err_invalid_token,
24
+ apf_err_missing_argument
25
+ };
26
+
27
+ extern enum apf_err apf_errno;
28
+
29
+ struct apf_fmte {
30
+ const char *parenarg_start;
31
+ const char *parenarg_end;
32
+ size_t parenarg_len;
33
+
34
+ const char *anglearg_start;
35
+ const char *anglearg_end;
36
+ size_t anglearg_len;
37
+
38
+ char chararg;
39
+
40
+ char padchar;
41
+
42
+ enum apf_argt type;
43
+ enum apf_align align;
44
+
45
+ long prec;
46
+ long pad;
47
+
48
+ void *value;
49
+
50
+ struct apf_fmte *next;
51
+ };
52
+
53
+ void apf_fmte_push(struct apf_fmte *, struct apf_fmte *);
54
+ void apf_fmte_destroy(struct apf_fmte *);
55
+ struct apf_fmte *apf_parse(const char **);
56
+ char *apf_assemble(struct apf_fmte *);
57
+ #endif
@@ -1,21 +1,20 @@
1
- #include <altprintf/syntax.h>
2
- #include <altprintf/strbuf.h>
3
- #include <altprintf/fmte.h>
4
- #include <altprintf/log.h>
5
- #include <altprintf/fmt.h>
1
+ #include "altprintf.h"
2
+ #include "syntax.h"
3
+ #include "strbuf.h"
4
+ #include "log.h"
6
5
 
7
6
  #define BUFNUM 25
8
7
 
9
8
  #define CHECKNULL(p) do { \
10
9
  if (p == NULL) { \
11
- apf_err = apfe_missing_argument; \
10
+ apf_errno = apf_err_missing_argument; \
12
11
  return; \
13
12
  } \
14
13
  } while (0)
15
14
 
16
- enum altprintf_err apf_err;
15
+ enum apf_err apf_errno;
17
16
 
18
- void fmt_mul(struct strbuf *sb, struct fmte *f)
17
+ static void fmt_mul(struct strbuf *sb, struct apf_fmte *f)
19
18
  {
20
19
  CHECKNULL(f->value);
21
20
 
@@ -29,7 +28,7 @@ void fmt_mul(struct strbuf *sb, struct fmte *f)
29
28
  strbuf_append_str(sb, f->parenarg_start, -f->parenarg_len);
30
29
  }
31
30
 
32
- void fmt_tern(struct strbuf *sb, struct fmte *f)
31
+ static void fmt_tern(struct strbuf *sb, struct apf_fmte *f)
33
32
  {
34
33
  CHECKNULL(f->parenarg_start);
35
34
  CHECKNULL(f->value);
@@ -50,7 +49,7 @@ void fmt_tern(struct strbuf *sb, struct fmte *f)
50
49
  }
51
50
  }
52
51
 
53
- char process_escape_seq(char seq)
52
+ static char process_escape_seq(char seq)
54
53
  {
55
54
  switch (seq) {
56
55
  case FS_ESC_NL:
@@ -74,7 +73,7 @@ char process_escape_seq(char seq)
74
73
  }
75
74
  }
76
75
 
77
- void fmt_raw(struct strbuf *sb, struct fmte *f)
76
+ static void fmt_raw(struct strbuf *sb, struct apf_fmte *f)
78
77
  {
79
78
  CHECKNULL(f->parenarg_start);
80
79
 
@@ -96,7 +95,7 @@ void fmt_raw(struct strbuf *sb, struct fmte *f)
96
95
  }
97
96
  }
98
97
 
99
- void fmt_string(struct strbuf *sb, struct fmte *f)
98
+ static void fmt_string(struct strbuf *sb, struct apf_fmte *f)
100
99
  {
101
100
  CHECKNULL(f->value);
102
101
 
@@ -104,26 +103,27 @@ void fmt_string(struct strbuf *sb, struct fmte *f)
104
103
  strbuf_append_str(sb, f->value, prec);
105
104
  }
106
105
 
107
- void fmt_char(struct strbuf *sb, struct fmte *f)
106
+ static void fmt_char(struct strbuf *sb, struct apf_fmte *f)
108
107
  {
109
108
  CHECKNULL(f->value);
110
109
  strbuf_append_char(sb, f->value);
111
110
  }
112
111
 
113
- void fmt_int(struct strbuf *sb, struct fmte *f)
112
+ static void fmt_int(struct strbuf *sb, struct apf_fmte *f)
114
113
  {
115
114
  CHECKNULL(f->value);
116
115
  strbuf_append_int(sb, f->value);
117
116
  }
118
117
 
119
- void fmt_double(struct strbuf *sb, struct fmte *f)
118
+ static void fmt_double(struct strbuf *sb, struct apf_fmte *f)
120
119
  {
121
120
  CHECKNULL(f->value);
122
121
  int prec = f->prec == -1 ? 3 : f->prec;
123
122
  strbuf_append_double(sb, f->value, prec);
124
123
  }
125
124
 
126
- void fmt(struct strbuf *sb, struct fmte *f, void (*fmtr)(struct strbuf *, struct fmte *))
125
+ static void
126
+ fmt(struct strbuf *sb, struct apf_fmte *f, void (*fmtr)(struct strbuf *, struct apf_fmte *))
127
127
  {
128
128
  struct strbuf *tmp = strbuf_new();
129
129
 
@@ -139,15 +139,15 @@ void fmt(struct strbuf *sb, struct fmte *f, void (*fmtr)(struct strbuf *, struct
139
139
  if (pad > 0) {
140
140
  LOG("padding: %d\n", pad);
141
141
  switch (f->align) {
142
- case Right:
142
+ case apf_algn_right:
143
143
  strbuf_append_strbuf(sb, tmp);
144
144
  strbuf_pad(sb, f->padchar, pad);
145
145
  break;
146
- case Left:
146
+ case apf_algn_left:
147
147
  strbuf_pad(sb, f->padchar, pad);
148
148
  strbuf_append_strbuf(sb, tmp);
149
149
  break;
150
- case Center:
150
+ case apf_algn_center:
151
151
  strbuf_pad(sb, f->padchar, pad / 2);
152
152
  strbuf_append_strbuf(sb, tmp);
153
153
  strbuf_pad(sb, f->padchar, pad / 2 + pad % 2);
@@ -160,16 +160,16 @@ void fmt(struct strbuf *sb, struct fmte *f, void (*fmtr)(struct strbuf *, struct
160
160
  strbuf_destroy(tmp);
161
161
  }
162
162
 
163
- char *assemble_fmt(struct fmte *head)
163
+ char *apf_assemble(struct apf_fmte *head)
164
164
  {
165
- struct fmte *f = head;
165
+ struct apf_fmte *f = head;
166
166
  struct strbuf *bufs[BUFNUM];
167
- struct fmte *splits[BUFNUM];
167
+ struct apf_fmte *splits[BUFNUM];
168
168
  size_t buf = 0, i;
169
169
  size_t w, tw, rw;
170
170
  char *final;
171
171
 
172
- void (*fmtr)(struct strbuf *, struct fmte *) = NULL;
172
+ void (*fmtr)(struct strbuf *, struct apf_fmte *) = NULL;
173
173
  int loop = 1;
174
174
 
175
175
  bufs[buf] = strbuf_new();
@@ -177,39 +177,39 @@ char *assemble_fmt(struct fmte *head)
177
177
  LOG("assembling elements\n");
178
178
  while (loop) {
179
179
  switch (f->type) {
180
- case FMul:
180
+ case apf_argt_mul:
181
181
  fmtr = fmt_mul;
182
182
  break;
183
- case FTern:
183
+ case apf_argt_tern:
184
184
  fmtr = fmt_tern;
185
185
  break;
186
- case FInt:
186
+ case apf_argt_int:
187
187
  fmtr = fmt_int;
188
188
  break;
189
- case FChar:
189
+ case apf_argt_char:
190
190
  fmtr = fmt_char;
191
191
  break;
192
- case FDouble:
192
+ case apf_argt_double:
193
193
  fmtr = fmt_double;
194
194
  break;
195
- case FString:
195
+ case apf_argt_string:
196
196
  fmtr = fmt_string;
197
197
  break;
198
- case FRaw:
198
+ case apf_argt_raw:
199
199
  fmtr = fmt_raw;
200
200
  break;
201
201
 
202
- case FAlign:
202
+ case apf_argt_align:
203
203
  buf++;
204
204
  splits[buf] = f;
205
205
  bufs[buf] = strbuf_new();
206
206
  fmtr = NULL;
207
207
  break;
208
- case FEnd:
208
+ case apf_argt_end:
209
209
  loop = 0;
210
210
  fmtr = NULL;
211
211
  break;
212
- case FNone:
212
+ case apf_argt_none:
213
213
  fmtr = NULL;
214
214
  break;
215
215
  }
@@ -6,13 +6,18 @@
6
6
  #undef RUBY_EXTCONF_H
7
7
  #endif
8
8
 
9
+ #ifdef DEBUG
10
+ #define LOG(...) printf("%s:%d [\e[35m%s\e[0m] ", __FILE__, __LINE__, __func__); printf(__VA_ARGS__);
11
+ #else
12
+ #define LOG(msg, ...)
13
+ #endif
14
+
9
15
  #include "extconf.h"
10
16
  #include <stdio.h>
11
17
  #include <locale.h>
12
18
  #include <ruby.h>
13
19
  #include <ruby/encoding.h>
14
- #include <altprintf/altprintf.h>
15
- #include <altprintf/log.h>
20
+ #include <altprintf.h>
16
21
 
17
22
  rb_encoding *enc;
18
23
 
@@ -45,7 +50,7 @@ VALUE cstorbs(const char *cstr)
45
50
  return str;
46
51
  }
47
52
 
48
- VALUE get_entry(struct fmte *f, size_t argc, size_t *argi, VALUE *argv, VALUE *hash)
53
+ VALUE get_entry(struct apf_fmte *f, size_t argc, size_t *argi, VALUE *argv, VALUE *hash)
49
54
  {
50
55
  VALUE sym, entry;
51
56
 
@@ -70,7 +75,7 @@ VALUE get_entry(struct fmte *f, size_t argc, size_t *argi, VALUE *argv, VALUE *h
70
75
 
71
76
  char *rb_apformat(const char *fmt, size_t argc, size_t *argi, VALUE *argv, VALUE *hash)
72
77
  {
73
- struct fmte *f, *head;
78
+ struct apf_fmte *f, *head;
74
79
  char *final;
75
80
  int loop = 1;
76
81
  long *tmpi;
@@ -80,42 +85,42 @@ char *rb_apformat(const char *fmt, size_t argc, size_t *argi, VALUE *argv, VALUE
80
85
  void *tmp;
81
86
  VALUE entry;
82
87
 
83
- head = f = parsef(&fmt);
88
+ head = f = apf_parse(&fmt);
84
89
 
85
90
  while (loop) {
86
- if (apf_err != apfe_none)
91
+ if (apf_errno != apf_err_none)
87
92
  rb_raise(rb_eArgError, "malformed format string");
88
93
 
89
94
  LOG("scanned type: %d\n", f->type);
90
95
 
91
- if (f->type != FEnd && f->type != FRaw)
96
+ if (f->type != apf_argt_end && f->type != apf_argt_raw)
92
97
  entry = get_entry(f, argc, argi, argv, hash);
93
98
  else
94
99
  entry = Qnil;
95
100
 
96
101
  switch (f->type) {
97
- case FString:
102
+ case apf_argt_string:
98
103
  Check_Type(entry, T_STRING);
99
104
 
100
105
  tmp = rbstocs(&entry);
101
106
  goto match;
102
- case FTern:
107
+ case apf_argt_tern:
103
108
  tmpi = malloc(sizeof(long));
104
109
 
105
110
  *tmpi = (entry == Qfalse || entry == Qnil) ? 0 : 1;
106
111
 
107
112
  tmp = tmpi;
108
113
  goto match;
109
- case FMul:
110
- case FAlign:
111
- case FInt:
114
+ case apf_argt_mul:
115
+ case apf_argt_align:
116
+ case apf_argt_int:
112
117
  Check_Type(entry, T_FIXNUM);
113
118
 
114
119
  tmpi = malloc(sizeof(long));
115
120
  *tmpi = FIX2LONG(entry);
116
121
  tmp = tmpi;
117
122
  goto match;
118
- case FChar:
123
+ case apf_argt_char:
119
124
  Check_Type(entry, T_STRING);
120
125
 
121
126
  tmpc = malloc(sizeof(char));
@@ -123,7 +128,7 @@ char *rb_apformat(const char *fmt, size_t argc, size_t *argi, VALUE *argv, VALUE
123
128
  *tmpc = tmps[0];
124
129
  tmp = tmpc;
125
130
  goto match;
126
- case FDouble:
131
+ case apf_argt_double:
127
132
  Check_Type(entry, T_FLOAT);
128
133
 
129
134
  tmpd = malloc(sizeof(double));
@@ -132,13 +137,13 @@ char *rb_apformat(const char *fmt, size_t argc, size_t *argi, VALUE *argv, VALUE
132
137
  match:
133
138
  f->value = tmp;
134
139
  break;
135
- case FRaw:
140
+ case apf_argt_raw:
136
141
  break;
137
- case FEnd:
142
+ case apf_argt_end:
138
143
  LOG("EOS (end of string)\n");
139
144
  loop = 0;
140
145
  break;
141
- case FNone:
146
+ case apf_argt_none:
142
147
  LOG("error! shouldn' t be none\n");
143
148
  break;
144
149
  }
@@ -147,15 +152,15 @@ match:
147
152
  #ifdef DEBUG
148
153
  fmte_inspect(f);
149
154
  #endif
150
- fmte_push(head, f);
155
+ apf_fmte_push(head, f);
151
156
  if (loop)
152
- f = parsef(&fmt);
157
+ f = apf_parse(&fmt);
153
158
  }
154
159
 
155
160
  LOG("got all fmt elements\n");
156
- final = assemble_fmt(head);
161
+ final = apf_assemble(head);
157
162
  LOG("assembled fmt: %s", final);
158
- fmte_destroy(head);
163
+ apf_fmte_destroy(head);
159
164
  return final;
160
165
  }
161
166
 
@@ -167,7 +172,7 @@ VALUE rb_altprintf(long passes, size_t argc, VALUE *argv, VALUE self)
167
172
  size_t argi;
168
173
  int free_wfmt;
169
174
 
170
- apf_err = apfe_none;
175
+ apf_errno = apf_err_none;
171
176
  rb_scan_args(argc, argv, "1*:", &fmt, &args, &hash);
172
177
  argc--;
173
178
 
@@ -10,12 +10,12 @@ module ExtconfHelper
10
10
  module_function
11
11
 
12
12
  def dev_setup
13
- unless find_header('altprintf/altprintf.h', INC_DIR)
13
+ unless find_header('altprintf.h', INC_DIR)
14
14
  $stderr.puts("couldn't find header 'altprintf.h'")
15
15
  exit(1)
16
16
  end
17
17
 
18
- unless find_library('altprintf', 'parsef', LIB_DIR)
18
+ unless find_library('altprintf', 'apf_parse', LIB_DIR)
19
19
  $stderr.puts("you haven't built libaltprintf yet")
20
20
  exit(1)
21
21
  end
@@ -1,12 +1,12 @@
1
1
  #include <stdlib.h>
2
2
  #include <stdio.h>
3
- #include <altprintf/enums.h>
4
- #include <altprintf/log.h>
5
- #include <altprintf/fmte.h>
3
+ #include "altprintf.h"
4
+ #include "fmte.h"
5
+ #include "log.h"
6
6
 
7
- struct fmte *fmte_ini(void)
7
+ struct apf_fmte *apf_fmte_ini(void)
8
8
  {
9
- struct fmte *f = malloc(sizeof(struct fmte));
9
+ struct apf_fmte *f = malloc(sizeof(struct apf_fmte));
10
10
 
11
11
  f->parenarg_start = NULL;
12
12
  f->parenarg_end = NULL;
@@ -18,8 +18,8 @@ struct fmte *fmte_ini(void)
18
18
 
19
19
  f->chararg = ' ';
20
20
  f->padchar = ' ';
21
- f->type = FNone;
22
- f->align = Left;
21
+ f->type = apf_argt_none;
22
+ f->align = apf_algn_left;
23
23
  f->prec = -1;
24
24
  f->pad = 0;
25
25
  f->value = NULL;
@@ -29,7 +29,7 @@ struct fmte *fmte_ini(void)
29
29
  return f;
30
30
  }
31
31
 
32
- void fmte_push(struct fmte *a, struct fmte *b)
32
+ void apf_fmte_push(struct apf_fmte *a, struct apf_fmte *b)
33
33
  {
34
34
  if (a == b)
35
35
  return; // refuse to create an infinite loop
@@ -39,9 +39,9 @@ void fmte_push(struct fmte *a, struct fmte *b)
39
39
  a->next = b;
40
40
  }
41
41
 
42
- void fmte_destroy(struct fmte *f)
42
+ void apf_fmte_destroy(struct apf_fmte *f)
43
43
  {
44
- struct fmte *j;
44
+ struct apf_fmte *j;
45
45
 
46
46
  while (f != NULL) {
47
47
  j = f->next;
@@ -51,7 +51,7 @@ void fmte_destroy(struct fmte *f)
51
51
  }
52
52
  }
53
53
 
54
- void fmte_inspect(struct fmte *f)
54
+ void apf_fmte_inspect(struct apf_fmte *f)
55
55
  {
56
56
  char *parenarg = calloc(f->parenarg_len + 1, sizeof(char));
57
57
  char *anglearg = calloc(f->anglearg_len + 1, sizeof(char));
@@ -0,0 +1,5 @@
1
+ #ifndef FMTE_H_
2
+ #define FMTE_H_
3
+ struct apf_fmte *apf_fmte_ini(void);
4
+ void apf_fmte_inspect(struct apf_fmte *);
5
+ #endif
@@ -3,10 +3,8 @@
3
3
 
4
4
  #ifdef DEBUG
5
5
  #define LOG(...) printf("%s:%d [\e[35m%s\e[0m] ", __FILE__, __LINE__, __func__); printf(__VA_ARGS__);
6
- #define FLOG(msg, ...) fprintf(stderr, "%s[%d] - "msg, __FILE__, __LINE__ __VA_OPT__(, ) __VA_ARGS__)
7
6
  #else
8
7
  #define LOG(msg, ...)
9
- #define FLOG(msg, ...)
10
8
  #endif
11
9
 
12
10
  #endif
@@ -1,11 +1,11 @@
1
- #include <altprintf/fmte.h>
2
- #include <altprintf/syntax.h>
3
- #include <altprintf/log.h>
4
- #include <altprintf/parsef.h>
1
+ #include "altprintf.h"
2
+ #include "fmte.h"
3
+ #include "syntax.h"
4
+ #include "log.h"
5
5
 
6
6
  char *altprintf_pct = "%";
7
7
 
8
- void get_longarg(const char **s, const char **e, char stop, size_t *size)
8
+ static void get_longarg(const char **s, const char **e, char stop, size_t *size)
9
9
  {
10
10
  *size = 0;
11
11
 
@@ -20,23 +20,23 @@ void get_longarg(const char **s, const char **e, char stop, size_t *size)
20
20
  *e = *s - 1;
21
21
  }
22
22
 
23
- struct fmte *parsef(const char **fmt)
23
+ struct apf_fmte *apf_parse(const char **fmt)
24
24
  {
25
25
  char *w_c;
26
26
  char **w_a = &w_c;
27
- struct fmte *f = fmte_ini();
27
+ struct apf_fmte *f = apf_fmte_ini();
28
28
  long *l_a = &f->pad;
29
29
 
30
30
  LOG("processing %d (%c)\n", **fmt, **fmt);
31
31
 
32
32
  if (**fmt != FS_START) {
33
33
  if (**fmt == EOS) {
34
- f->type = FEnd;
34
+ f->type = apf_argt_end;
35
35
  goto return_format;
36
36
  }
37
37
 
38
38
  LOG("building raw format\n");
39
- f->type = FRaw;
39
+ f->type = apf_argt_raw;
40
40
 
41
41
  f->parenarg_start = *fmt;
42
42
  LOG("scanning long arg\n");
@@ -68,10 +68,10 @@ struct fmte *parsef(const char **fmt)
68
68
  get_longarg(fmt, &f->parenarg_end, FS_A_PARENARG_E, &f->parenarg_len);
69
69
  break;
70
70
  case FS_A_LALIGN:
71
- f->align = Left;
71
+ f->align = apf_algn_left;
72
72
  break;
73
73
  case FS_A_CALIGN:
74
- f->align = Center;
74
+ f->align = apf_algn_center;
75
75
  break;
76
76
  case FS_A_PAD:
77
77
  (*fmt)++;
@@ -89,40 +89,40 @@ struct fmte *parsef(const char **fmt)
89
89
  break;
90
90
  // Psuedo-type
91
91
  case FS_START:
92
- f->type = FRaw;
92
+ f->type = apf_argt_raw;
93
93
  f->parenarg_start = &altprintf_pct[0];
94
94
  f->parenarg_end = &altprintf_pct[1];
95
95
  f->parenarg_len = 1;
96
96
  goto return_format;
97
97
  // Types
98
98
  case FS_T_STRING:
99
- f->type = FString;
99
+ f->type = apf_argt_string;
100
100
  goto return_format;
101
101
  case FS_T_MUL:
102
- f->type = FMul;
102
+ f->type = apf_argt_mul;
103
103
  goto return_format;
104
104
  case FS_T_TERN:
105
- f->type = FTern;
105
+ f->type = apf_argt_tern;
106
106
  goto return_format;
107
107
  case FS_T_ALIGN:
108
- f->type = FAlign;
108
+ f->type = apf_argt_align;
109
109
  goto return_format;
110
110
  case FS_T_INT:
111
- f->type = FInt;
111
+ f->type = apf_argt_int;
112
112
  goto return_format;
113
113
  case FS_T_CHAR:
114
- f->type = FChar;
114
+ f->type = apf_argt_char;
115
115
  goto return_format;
116
116
  case FS_T_DOUBLE:
117
- f->type = FDouble;
117
+ f->type = apf_argt_double;
118
118
  goto return_format;
119
119
  default:
120
- apf_err = apfe_invalid_token;
121
- f->type = FRaw;
120
+ apf_errno = apf_err_invalid_token;
121
+ f->type = apf_argt_raw;
122
122
  }
123
123
  }
124
124
 
125
- f->type = FEnd;
125
+ f->type = apf_argt_end;
126
126
  return_format:
127
127
  (*fmt)++;
128
128
  return f;
@@ -6,11 +6,9 @@
6
6
  #include <stdlib.h>
7
7
  #include <stdio.h>
8
8
  #include <string.h>
9
- #include <altprintf/log.h>
10
- #include <altprintf/strbuf.h>
11
- #include <altprintf/cwidth.h>
12
-
13
- extern struct lconv *locale_info;
9
+ #include "log.h"
10
+ #include "strbuf.h"
11
+ #include "cwidth.h"
14
12
 
15
13
  struct strbuf *strbuf_new(void)
16
14
  {
@@ -1,3 +1,3 @@
1
1
  module Altprintf
2
- VERSION ||= "0.3.3"
2
+ VERSION ||= "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: altprintf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stone Tickle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -74,24 +74,21 @@ extensions:
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - altprintf.gemspec
77
- - ext/altprintf/altprintf/altprintf.h
78
- - ext/altprintf/altprintf/cwidth.h
79
- - ext/altprintf/altprintf/enums.h
80
- - ext/altprintf/altprintf/fmt.h
81
- - ext/altprintf/altprintf/fmte.h
82
- - ext/altprintf/altprintf/log.h
83
- - ext/altprintf/altprintf/parsef.h
84
- - ext/altprintf/altprintf/strbuf.h
85
- - ext/altprintf/altprintf/syntax.h
77
+ - ext/altprintf/altprintf.h
78
+ - ext/altprintf/assemble.c
86
79
  - ext/altprintf/cwidth.c
80
+ - ext/altprintf/cwidth.h
87
81
  - ext/altprintf/ext.c
88
82
  - ext/altprintf/extconf.h
89
83
  - ext/altprintf/extconf.rb
90
84
  - ext/altprintf/extconf_helper.rb
91
- - ext/altprintf/fmt.c
92
85
  - ext/altprintf/fmte.c
93
- - ext/altprintf/parsef.c
86
+ - ext/altprintf/fmte.h
87
+ - ext/altprintf/log.h
88
+ - ext/altprintf/parse.c
94
89
  - ext/altprintf/strbuf.c
90
+ - ext/altprintf/strbuf.h
91
+ - ext/altprintf/syntax.h
95
92
  - lib/altprintf.rb
96
93
  - lib/altprintf/version.rb
97
94
  - readme.md
@@ -114,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
111
  - !ruby/object:Gem::Version
115
112
  version: '0'
116
113
  requirements: []
117
- rubygems_version: 3.0.3
114
+ rubygems_version: 3.0.6
118
115
  signing_key:
119
116
  specification_version: 4
120
117
  summary: A powerful printf-like template language
@@ -1,8 +0,0 @@
1
- #ifndef ALTPRINTF_H_
2
- #define ALTPRINTF_H_
3
- #define ALTPRINTF_VERSION "0.3.3"
4
-
5
- #include <altprintf/fmt.h>
6
- #include <altprintf/fmte.h>
7
- #include <altprintf/parsef.h>
8
- #endif
@@ -1,14 +0,0 @@
1
- #ifndef _ALTPRINTF_ENUM_H
2
- #define _ALTPRINTF_ENUM_H
3
- enum arg_type { FMul, FTern, FAlign, FInt, FChar, FDouble, FString, FRaw, FNone,
4
- FEnd };
5
- enum align { Left, Right, Center };
6
-
7
- enum altprintf_err {
8
- apfe_none,
9
- apfe_invalid_token,
10
- apfe_missing_argument
11
- };
12
-
13
- extern enum altprintf_err apf_err;
14
- #endif
@@ -1,5 +0,0 @@
1
- #ifndef FMT_H_
2
- #define FMT_H_
3
- #include <altprintf/fmte.h>
4
- char *assemble_fmt(struct fmte *);
5
- #endif
@@ -1,34 +0,0 @@
1
- #ifndef FMTE_H_
2
- #define FMTE_H_
3
- #include <stdlib.h>
4
- #include <altprintf/enums.h>
5
-
6
- struct fmte {
7
- const char *parenarg_start;
8
- const char *parenarg_end;
9
- size_t parenarg_len;
10
-
11
- const char *anglearg_start;
12
- const char *anglearg_end;
13
- size_t anglearg_len;
14
-
15
- char chararg;
16
-
17
- char padchar;
18
-
19
- enum arg_type type;
20
- enum align align;
21
-
22
- long prec;
23
- long pad;
24
-
25
- void *value;
26
-
27
- struct fmte *next;
28
- };
29
-
30
- struct fmte *fmte_ini(void);
31
- void fmte_inspect(struct fmte *);
32
- void fmte_push(struct fmte *, struct fmte *);
33
- void fmte_destroy(struct fmte *);
34
- #endif
@@ -1,6 +0,0 @@
1
- #ifndef PARSEF_H_
2
- #define PARSEF_H_
3
- #include <stdlib.h>
4
-
5
- struct fmte *parsef(const char **);
6
- #endif