alt_printf 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +8 -2
- data/alt_printf.gemspec +1 -1
- data/ext/alt_printf/alt_printf.c +135 -147
- data/ext/alt_printf/altprintf.h +4 -41
- data/ext/alt_printf/enums.h +6 -0
- data/ext/alt_printf/extconf.h +1 -0
- data/ext/alt_printf/extconf.rb +2 -3
- data/ext/alt_printf/extconf_debug.rb +4 -0
- data/ext/alt_printf/extconf_dev.rb +2 -7
- data/ext/alt_printf/extconf_helper.rb +35 -0
- data/ext/alt_printf/fmt.c +174 -0
- data/ext/alt_printf/fmt.h +8 -0
- data/ext/alt_printf/fmte.c +92 -0
- data/ext/alt_printf/fmte.h +37 -0
- data/ext/alt_printf/log.h +2 -1
- data/ext/alt_printf/parsef.c +125 -0
- data/ext/alt_printf/parsef.h +10 -0
- data/ext/alt_printf/strbuf.c +44 -26
- data/ext/alt_printf/strbuf.h +12 -3
- data/ext/alt_printf/syntax.h +8 -5
- data/lib/alt_printf/alt_printf.so +0 -0
- data/lib/alt_printf/version.rb +1 -1
- metadata +12 -6
- data/ext/alt_printf/altprintf.c +0 -250
- data/ext/alt_printf/list.c +0 -81
- data/ext/alt_printf/list.h +0 -24
data/ext/alt_printf/list.c
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
#include "list.h"
|
2
|
-
#include "log.h"
|
3
|
-
|
4
|
-
struct list_elem *list_elem_create() {
|
5
|
-
void *null = NULL;
|
6
|
-
struct list_elem *le = malloc(sizeof(struct list_elem));
|
7
|
-
LOG("allocatted %zu %p\n", sizeof(struct list_elem), le);
|
8
|
-
le->data = null;
|
9
|
-
le->type = Null;
|
10
|
-
le->next = null;
|
11
|
-
le->heap = 1;
|
12
|
-
|
13
|
-
return le;
|
14
|
-
}
|
15
|
-
|
16
|
-
void list_elem_destroy(struct list_elem *le) {
|
17
|
-
if (le->heap && le->data != NULL) {
|
18
|
-
LOG("freeing %p\n", le->data);
|
19
|
-
free(le->data);
|
20
|
-
}
|
21
|
-
if (le->next != NULL) { list_elem_destroy(le->next); }
|
22
|
-
|
23
|
-
LOG("freeing %p\n", le);
|
24
|
-
free(le);
|
25
|
-
}
|
26
|
-
|
27
|
-
struct list_elem *list_elem_ini(void *data, enum type t) {
|
28
|
-
struct list_elem *le = list_elem_create();
|
29
|
-
le->data = data;
|
30
|
-
le->type = t;
|
31
|
-
return le;
|
32
|
-
}
|
33
|
-
|
34
|
-
struct list_elem *list_elem_ini_str(wchar_t *str) {
|
35
|
-
struct list_elem *le = list_elem_create();
|
36
|
-
le->data = str;
|
37
|
-
le->type = String;
|
38
|
-
return le;
|
39
|
-
}
|
40
|
-
|
41
|
-
struct list_elem *list_elem_ini_int(long int *i) {
|
42
|
-
struct list_elem *le = list_elem_create();
|
43
|
-
le->data = i;
|
44
|
-
le->type = Int;
|
45
|
-
return le;
|
46
|
-
}
|
47
|
-
|
48
|
-
struct list_elem *list_elem_ini_dub(double *d) {
|
49
|
-
struct list_elem *le = list_elem_create();
|
50
|
-
le->data = d;
|
51
|
-
le->type = Double;
|
52
|
-
return le;
|
53
|
-
}
|
54
|
-
|
55
|
-
void list_elem_inspect(struct list_elem *le) {
|
56
|
-
switch (le->type) {
|
57
|
-
case Int:
|
58
|
-
printf("->Int %ld\n", *(long int *)le->data);
|
59
|
-
break;
|
60
|
-
case String:
|
61
|
-
printf("->String '%ls'\n", (wchar_t *)le->data);
|
62
|
-
break;
|
63
|
-
case Char:
|
64
|
-
printf("->Char %lc\n", *(wint_t *)le->data);
|
65
|
-
break;
|
66
|
-
case Double:
|
67
|
-
printf("->Double %f\n", *(double *)le->data);
|
68
|
-
break;
|
69
|
-
case Null:
|
70
|
-
printf("->Null\n");
|
71
|
-
break;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
void list_elem_inspect_all(struct list_elem *le) {
|
76
|
-
while(1) {
|
77
|
-
list_elem_inspect(le);
|
78
|
-
if (le->next == NULL) { break; }
|
79
|
-
le = le->next;
|
80
|
-
}
|
81
|
-
}
|
data/ext/alt_printf/list.h
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#ifndef LIST_H
|
2
|
-
#define LIST_H
|
3
|
-
#include <stdio.h>
|
4
|
-
#include <stdlib.h>
|
5
|
-
#include <wchar.h>
|
6
|
-
|
7
|
-
enum type { Int, String, Char, Double, Null };
|
8
|
-
|
9
|
-
struct list_elem {
|
10
|
-
void *data;
|
11
|
-
enum type type;
|
12
|
-
struct list_elem *next;
|
13
|
-
int heap;
|
14
|
-
};
|
15
|
-
|
16
|
-
struct list_elem *list_elem_create();
|
17
|
-
void list_elem_destroy(struct list_elem *le);
|
18
|
-
struct list_elem *list_elem_ini(void *data, enum type t);
|
19
|
-
struct list_elem *list_elem_ini_int(long int *i);
|
20
|
-
struct list_elem *list_elem_ini_str(wchar_t *str);
|
21
|
-
struct list_elem *list_elem_ini_dub(double *d);
|
22
|
-
void list_elem_inspect(struct list_elem *le);
|
23
|
-
void list_elem_inspect_all(struct list_elem *le);
|
24
|
-
#endif
|