Browse Source

add dynamic version to build via meson

remove unused arg in misc
mark arg as unused in addtax
update translations
Chris Cromer 2 months ago
parent
commit
43ea64918b
Signed by: Chris Cromer <chris@cromer.cl> GPG Key ID: 39CC813FF3C8708A
10 changed files with 44 additions and 26 deletions
  1. 8
    2
      meson.build
  2. 2
    2
      po/addtax.pot
  3. 2
    2
      po/es.po
  4. 5
    8
      src/addtax.c
  5. 3
    0
      src/include/addtax.h.in
  6. 5
    0
      src/include/meson.build
  7. 1
    0
      src/include/misc.h
  8. 14
    7
      src/meson.build
  9. 4
    4
      src/misc.c
  10. 0
    1
      src/misc.h

+ 8
- 2
meson.build View File

@@ -1,10 +1,16 @@
1 1
 project('addtax',
2 2
 	'c',
3
-	version : '1.0.0',
3
+	version : '1.0.2',
4 4
 	license : 'BSD-3',
5
-	default_options : [ 'b_ofast=if-release', 'b_march_native=if-release', 'b_ndebug=if-release' ]
5
+	default_options : [ 'b_ofast=if-release',
6
+		'b_march_native=if-release',
7
+		'b_ndebug=if-release',
8
+		'warning_level=3',
9
+		'c_std=c11'
10
+	]
6 11
 )
7 12
 add_global_arguments('-DGETTEXT_PACKAGE="addtax"', language: 'c')
8 13
 subdir('po')
9 14
 subdir('glade')
15
+subdir('src/include')
10 16
 subdir('src')

+ 2
- 2
po/addtax.pot View File

@@ -8,7 +8,7 @@ msgid ""
8 8
 msgstr ""
9 9
 "Project-Id-Version: addtax\n"
10 10
 "Report-Msgid-Bugs-To: \n"
11
-"POT-Creation-Date: 2018-09-24 16:16-0300\n"
11
+"POT-Creation-Date: 2018-09-25 16:35-0300\n"
12 12
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 13
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 14
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,7 +17,7 @@ msgstr ""
17 17
 "Content-Type: text/plain; charset=CHARSET\n"
18 18
 "Content-Transfer-Encoding: 8bit\n"
19 19
 
20
-#: src/addtax.c:51 src/addtax.c:65
20
+#: src/addtax.c:48 src/addtax.c:62
21 21
 #, c-format
22 22
 msgid "Usage: %s [prices...]\n"
23 23
 msgstr ""

+ 2
- 2
po/es.po View File

@@ -7,7 +7,7 @@ msgid ""
7 7
 msgstr ""
8 8
 "Project-Id-Version: addtax\n"
9 9
 "Report-Msgid-Bugs-To: \n"
10
-"POT-Creation-Date: 2018-09-24 16:16-0300\n"
10
+"POT-Creation-Date: 2018-09-25 16:35-0300\n"
11 11
 "PO-Revision-Date: 2018-09-13 10:10-0300\n"
12 12
 "Last-Translator: Chris Cromer <chris@cromer.cl>\n"
13 13
 "Language-Team: none\n"
@@ -18,7 +18,7 @@ msgstr ""
18 18
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19 19
 "X-Generator: Poedit 2.0.6\n"
20 20
 
21
-#: src/addtax.c:51 src/addtax.c:65
21
+#: src/addtax.c:48 src/addtax.c:62
22 22
 #, c-format
23 23
 msgid "Usage: %s [prices...]\n"
24 24
 msgstr "Uso: %s [precios...]\n"

+ 5
- 8
src/addtax.c View File

@@ -4,11 +4,8 @@
4 4
 #include <locale.h>
5 5
 #include <stdbool.h>
6 6
 #include <getopt.h>
7
-#include "misc.h"
8
-
9
-#define _(STRING) gettext(STRING)
10
-#define TAX 1.111111111
11
-#define VERSION "1.0.1"
7
+#include "include/addtax.h"
8
+#include "include/misc.h"
12 9
 
13 10
 GtkLabel *calculated_value = NULL;
14 11
 
@@ -18,7 +15,7 @@ void calculate_tax(GtkWidget *entry) {
18 15
 	const gchar *label_text;
19 16
 	entry_text = (char*) gtk_entry_get_text(GTK_ENTRY(entry));
20 17
 	money = atof(entry_text);
21
-	if (is_float(entry_text, money)) {
18
+	if (is_float(entry_text)) {
22 19
 		g_print("$%d * %f = ", (int) round(money), TAX);
23 20
 		money = money * TAX;
24 21
 		g_print("$%d\n", (int) round(money));
@@ -56,7 +53,7 @@ int main(int argc, char *argv[]) {
56 53
 		// Process arguments that are not options
57 54
 		while (optind < argc) {
58 55
 			money = atof(argv[optind]);
59
-			if (is_float(argv[optind++], money)) {
56
+			if (is_float(argv[optind++])) {
60 57
 				printf("$%d * %f = ", (int) round(money), TAX);
61 58
 				money = money * TAX;
62 59
 				printf("$%d\n", (int) round(money));
@@ -96,7 +93,7 @@ int main(int argc, char *argv[]) {
96 93
 }
97 94
 
98 95
 // Called when calculate is clicked
99
-void on_button_calculate_clicked(GtkWidget *button, GtkWidget *entry) {
96
+void on_button_calculate_clicked(__attribute__((unused)) GtkWidget *button, GtkWidget *entry) {
100 97
 	calculate_tax(entry);
101 98
 }
102 99
 

+ 3
- 0
src/include/addtax.h.in View File

@@ -0,0 +1,3 @@
1
+#define _(STRING) gettext(STRING)
2
+#define TAX 1.111111111
3
+#define VERSION "@version@"

+ 5
- 0
src/include/meson.build View File

@@ -0,0 +1,5 @@
1
+conf_data = configuration_data()
2
+conf_data.set('version', meson.project_version())
3
+configure_file(input : 'addtax.h.in',
4
+	output : 'addtax.h',
5
+	configuration : conf_data)

+ 1
- 0
src/include/misc.h View File

@@ -0,0 +1 @@
1
+bool is_float(const char *string);

+ 14
- 7
src/meson.build View File

@@ -6,18 +6,25 @@ gmodule_dep = dependency('gmodule-export-2.0', version : '>=2.0')
6 6
 cc = meson.get_compiler('c')
7 7
 m_dep = cc.find_library('m', required : false)
8 8
 
9
-# -no-pie so that the executable is double clickable in gui
10
-c_args = ['-no-pie']
11
-link_args = ['-no-pie']
12
-
13 9
 sources = ['addtax.c']
14 10
 sources += ['misc.c']
15
-sources += ['misc.h']
16 11
 sources += [main_resource_c]
17 12
 
13
+# -no-pie so that the executable is double clickable in gui
14
+if cc.get_id() == 'gcc'
15
+	c_args = ['-no-pie']
16
+	link_args = ['-no-pie']
17
+else
18
+	c_args = ''
19
+	link_args = ''
20
+endif
21
+
22
+inc = include_directories('include')
23
+
18 24
 executable('addtax',
19 25
 	sources,
20
-	c_args : c_args,
21
-	link_args : link_args,
26
+	include_directories : inc,
27
+	c_args: c_args,
28
+	link_args: link_args,
22 29
 	dependencies : [gtk_dep, m_dep, gmodule_dep],
23 30
 	install : true)

+ 4
- 4
src/misc.c View File

@@ -3,13 +3,13 @@
3 3
 #include <ctype.h>
4 4
 #include <stdlib.h>
5 5
 
6
-bool is_float(const char *s, float dest) {
7
-	if (s == NULL) {
6
+bool is_float(const char *string) {
7
+	if (string == NULL) {
8 8
 		return false;
9 9
 	}
10 10
 	char *endptr;
11
-	dest = (float) strtod(s, &endptr);
12
-	if (s == endptr) {
11
+	strtod(string, &endptr);
12
+	if (string == endptr) {
13 13
 		return false;
14 14
 	}
15 15
 	while (isspace((unsigned char ) *endptr)) {

+ 0
- 1
src/misc.h View File

@@ -1 +0,0 @@
1
-bool is_float(const char *s, float dest);

Loading…
Cancel
Save