Skip to contentSkip to conversation

speakup: Generate speakupmap.h automatically

PATCH Superseded Samuel Thibault 2 participants 9 messages Apr 30, 2022 – May 15, 2022 Speakup console speech driver

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Samuel Thibault

author maintainer
#0 lore raw

PATCH 1/1 speakup: Generate speakupmap.h automatically

speakupmap.h was not actually intended to be source code, speakupmap.map is.

This resurrects the makemapdata.c and genmap.c tools to generate speakupmap.h automatically from the input and speakup headers, and the speakupmap.map keyboard mapping source file.

---
 drivers/accessibility/speakup/Makefile      |   26 ++++
 drivers/accessibility/speakup/genmap.c      |  162 ++++++++++++++++++++++++++++
 drivers/accessibility/speakup/makemapdata.c |  125 +++++++++++++++++++++
 drivers/accessibility/speakup/speakupmap.h  |   66 -----------
 drivers/accessibility/speakup/utils.c       |   92 +++++++++++++++
 drivers/accessibility/speakup/utils.h       |   33 +++++
 6 files changed, 438 insertions(+), 66 deletions(-)
drivers/accessibility/speakup/Makefile +26 -0
@@ -30,3 +30,29 @@ speakup-y := \
 	thread.o \
 	varhandlers.o
 speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o
+
+
+clean-files := mapdata.h speakupmap.h
+
+
+# Generate mapdata.h from headers
+hostprogs += makemapdata
+makemapdata-objs := makemapdata.o utils.o
+
+quiet_cmd_mkmap = MKMAP   $@
+      cmd_mkmap = $(obj)/makemapdata > $@
+
+$(obj)/mapdata.h: $(obj)/makemapdata
+	$(call cmd,mkmap)
+
+
+# Generate speakupmap.map from mapdata.h
+hostprogs += genmap
+genmap-objs := genmap.o utils.o
+$(obj)/genmap.o: $(obj)/mapdata.h
+
+quiet_cmd_genmap = GENMAP  $@
+      cmd_genmap = $(obj)/genmap $< > $@
+
+$(obj)/speakupmap.h: $(obj)/speakupmap.map $(obj)/genmap
+	$(call cmd,genmap)
drivers/accessibility/speakup/genmap.c new file +162 -0

162 lines not on this page · raw message

drivers/accessibility/speakup/makemapdata.c new file +125 -0

125 lines not on this page · raw message

drivers/accessibility/speakup/speakupmap.h deleted +0 -66

66 lines not on this page · raw message

drivers/accessibility/speakup/utils.c new file +92 -0

92 lines not on this page · raw message

drivers/accessibility/speakup/utils.h new file +33 -0
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* utils.h
+ * originally written by: Kirk Reiser.
+ *
+ ** Copyright (C) 2002  Kirk Reiser.
+ *  Copyright (C) 2003  David Borowski.
+ */
+
+#include <stdio.h>
+
+#define MAXKEYS 512
+#define MAXKEYVAL 160
+#define HASHSIZE 101
+#define is_shift -3
+#define is_spk -2
+#define is_input -1
+
+struct st_key {
+	char *name;
+	struct st_key *next;
+	int value, shift;
+};
+
+extern struct st_key key_table[MAXKEYS];
+extern char *def_name, *def_val;
+extern FILE *infile;
+extern int lc;
+
+void open_input(const char *dirname, const char *name);
+int oops(const char *msg, const char *info);
+struct st_key *hash_name(char *name);
+struct st_key *find_key(char *name);
+struct st_key *add_key(char *name, int value, int shift);
author maintainer
#1 lore raw

PATCH v2 1/1 speakup: Generate speakupmap.h automatically

speakupmap.h was not actually intended to be source code, speakupmap.map is.

This resurrects the makemapdata.c and genmap.c tools to generate speakupmap.h automatically from the input and speakup headers, and the speakupmap.map keyboard mapping source file.

---
difference with v1:
- Add missing dependency between main.c and speakupmap.h

 drivers/accessibility/speakup/Makefile      |   28 ++++
 drivers/accessibility/speakup/genmap.c      |  162 ++++++++++++++++++++++++++++
 drivers/accessibility/speakup/makemapdata.c |  125 +++++++++++++++++++++
 drivers/accessibility/speakup/speakupmap.h  |   66 -----------
 drivers/accessibility/speakup/utils.c       |   92 +++++++++++++++
 drivers/accessibility/speakup/utils.h       |   33 +++++
 6 files changed, 440 insertions(+), 66 deletions(-)
drivers/accessibility/speakup/Makefile +28 -0
@@ -30,3 +30,31 @@ speakup-y := \
 	thread.o \
 	varhandlers.o
 speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o
+
+
+clean-files := mapdata.h speakupmap.h
+
+
+# Generate mapdata.h from headers
+hostprogs += makemapdata
+makemapdata-objs := makemapdata.o utils.o
+
+quiet_cmd_mkmap = MKMAP   $@
+      cmd_mkmap = $(obj)/makemapdata > $@
+
+$(obj)/mapdata.h: $(obj)/makemapdata
+	$(call cmd,mkmap)
+
+
+# Generate speakupmap.map from mapdata.h
+hostprogs += genmap
+genmap-objs := genmap.o utils.o
+$(obj)/genmap.o: $(obj)/mapdata.h
+
+quiet_cmd_genmap = GENMAP  $@
+      cmd_genmap = $(obj)/genmap $< > $@
+
+$(obj)/speakupmap.h: $(obj)/speakupmap.map $(obj)/genmap
+	$(call cmd,genmap)
+
+$(obj)/main.o: $(obj)/speakupmap.h
drivers/accessibility/speakup/genmap.c new file +162 -0

162 lines not on this page · raw message

drivers/accessibility/speakup/makemapdata.c new file +125 -0

125 lines not on this page · raw message

drivers/accessibility/speakup/speakupmap.h deleted +0 -66

66 lines not on this page · raw message

drivers/accessibility/speakup/utils.c new file +92 -0

92 lines not on this page · raw message

drivers/accessibility/speakup/utils.h new file +33 -0
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* utils.h
+ * originally written by: Kirk Reiser.
+ *
+ ** Copyright (C) 2002  Kirk Reiser.
+ *  Copyright (C) 2003  David Borowski.
+ */
+
+#include <stdio.h>
+
+#define MAXKEYS 512
+#define MAXKEYVAL 160
+#define HASHSIZE 101
+#define is_shift -3
+#define is_spk -2
+#define is_input -1
+
+struct st_key {
+	char *name;
+	struct st_key *next;
+	int value, shift;
+};
+
+extern struct st_key key_table[MAXKEYS];
+extern char *def_name, *def_val;
+extern FILE *infile;
+extern int lc;
+
+void open_input(const char *dirname, const char *name);
+int oops(const char *msg, const char *info);
+struct st_key *hash_name(char *name);
+struct st_key *find_key(char *name);
+struct st_key *add_key(char *name, int value, int shift);
#2 lore raw
Quoted 13 lines · Samuel Thibault

speakupmap.h was not actually intended to be source code, speakupmap.map is.

This resurrects the makemapdata.c and genmap.c tools to generate speakupmap.h automatically from the input and speakup headers, and the speakupmap.map keyboard mapping source file.

---
difference with v1:
- Add missing dependency between main.c and speakupmap.h

Quoted 7 lines
 drivers/accessibility/speakup/Makefile      |   28 ++++
 drivers/accessibility/speakup/genmap.c      |  162 ++++++++++++++++++++++++++++
 drivers/accessibility/speakup/makemapdata.c |  125 +++++++++++++++++++++
 drivers/accessibility/speakup/speakupmap.h  |   66 -----------
 drivers/accessibility/speakup/utils.c       |   92 +++++++++++++++
 drivers/accessibility/speakup/utils.h       |   33 +++++
 6 files changed, 440 insertions(+), 66 deletions(-)

Any reason you can't add the code in utils.c into genmap.c and then merge into makemapdata.c to make this a single .c file that does both things?

And when this is applied, I get the following "extra" files in the tree that need to be properly ignored, so I couldn't take this as-is anyway:

❯ git status
On branch work-testing
Untracked files:
(use "git add <file>..." to include in what will be committed)
drivers/accessibility/speakup/genmap drivers/accessibility/speakup/makemapdata drivers/accessibility/speakup/mapdata.h drivers/accessibility/speakup/speakupmap.h

nothing added to commit but untracked files present (use "git add" to track)

thanks,

greg k-h

author maintainer
#3 lore raw

Hello,

Greg KH, le lun. 09 mai 2022 16:04:43 +0200, a ecrit:

Quoted 3 lines

Any reason you can't add the code in utils.c into genmap.c and then merge into makemapdata.c to make this a single .c file that does both things?

Yes: genmap is a tool that end-users can use without needing the Linux source code, while makemapdata needs it.

Quoted 2 lines

And when this is applied, I get the following "extra" files in the tree that need to be properly ignored, so I couldn't take this as-is anyway:

Oh, right, I'll fix them.

Samuel

#4 lore raw
Quoted 9 lines · Samuel Thibault

Hello,

Greg KH, le lun. 09 mai 2022 16:04:43 +0200, a ecrit:

Quoted 3 lines

Any reason you can't add the code in utils.c into genmap.c and then merge into makemapdata.c to make this a single .c file that does both things?

Yes: genmap is a tool that end-users can use without needing the Linux source code, while makemapdata needs it.

But who will run genmap?

Also you could just put the 90 lines of code into the .h file as inline functions to get rid of the utils.c to make it a bit simpler.

thanks,

greg k-h

author maintainer
#5 lore raw

Greg KH, le lun. 09 mai 2022 16:19:03 +0200, a ecrit:

Quoted 10 lines · Samuel Thibault
Quoted 7 lines

Greg KH, le lun. 09 mai 2022 16:04:43 +0200, a ecrit:

Quoted 3 lines

Any reason you can't add the code in utils.c into genmap.c and then merge into makemapdata.c to make this a single .c file that does both things?

Yes: genmap is a tool that end-users can use without needing the Linux source code, while makemapdata needs it.

But who will run genmap?

I guess you meant makemapdata?

Long-term-wise this patchset will need a bit of work to properly install the genmap tool so the user can call it. I'm here mostly making sure to put into the Linux kernel how speakupmap.h is generated (rather than the currently very magic file), while at the same time keeping the separation between makemapdata and genmap that will make sense longterm-wise.

Samuel

#6 lore raw
Quoted 12 lines · Samuel Thibault

Greg KH, le lun. 09 mai 2022 16:19:03 +0200, a ecrit:

Quoted 10 lines · Samuel Thibault
Quoted 7 lines

Greg KH, le lun. 09 mai 2022 16:04:43 +0200, a ecrit:

Quoted 3 lines

Any reason you can't add the code in utils.c into genmap.c and then merge into makemapdata.c to make this a single .c file that does both things?

Yes: genmap is a tool that end-users can use without needing the Linux source code, while makemapdata needs it.

But who will run genmap?

Quoted 8 lines

I guess you meant makemapdata?

Long-term-wise this patchset will need a bit of work to properly install the genmap tool so the user can call it. I'm here mostly making sure to put into the Linux kernel how speakupmap.h is generated (rather than the currently very magic file), while at the same time keeping the separation between makemapdata and genmap that will make sense longterm-wise.

Ok, then it's ok to leave it as is. But the build stuff still needs to get resolved :)

author maintainer
#7 lore raw

Greg KH, le lun. 09 mai 2022 18:28:54 +0200, a ecrit:

Quoted 1 line

But the build stuff still needs to get resolved :)

Sure! I was just flushing the questions :)

Samuel

author maintainer
#8 lore raw

PATCH v3 1/1 speakup: Generate speakupmap.h automatically

In reply to Samuel Thibault

speakupmap.h was not actually intended to be source code, speakupmap.map is.

This resurrects the makemapdata.c and genmap.c tools to generate speakupmap.h automatically from the input and speakup headers, and the speakupmap.map keyboard mapping source file.

---
difference with v2:
- Stuff utils.c into utils.h
- Add .gitignore

difference with v1:
- Add missing dependency between main.c and speakupmap.h

 drivers/accessibility/speakup/.gitignore    |    4 
 drivers/accessibility/speakup/Makefile      |   28 ++++
 drivers/accessibility/speakup/genmap.c      |  162 ++++++++++++++++++++++++++++
 drivers/accessibility/speakup/makemapdata.c |  125 +++++++++++++++++++++
 drivers/accessibility/speakup/speakupmap.h  |   66 -----------
 drivers/accessibility/speakup/utils.h       |   99 +++++++++++++++++
 6 files changed, 418 insertions(+), 66 deletions(-)
drivers/accessibility/speakup/Makefile +28 -0
@@ -30,3 +30,31 @@ speakup-y := \
 	thread.o \
 	varhandlers.o
 speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o
+
+
+clean-files := mapdata.h speakupmap.h
+
+
+# Generate mapdata.h from headers
+hostprogs += makemapdata
+makemapdata-objs := makemapdata.o
+
+quiet_cmd_mkmap = MKMAP   $@
+      cmd_mkmap = $(obj)/makemapdata > $@
+
+$(obj)/mapdata.h: $(obj)/makemapdata
+	$(call cmd,mkmap)
+
+
+# Generate speakupmap.map from mapdata.h
+hostprogs += genmap
+genmap-objs := genmap.o
+$(obj)/genmap.o: $(obj)/mapdata.h
+
+quiet_cmd_genmap = GENMAP  $@
+      cmd_genmap = $(obj)/genmap $< > $@
+
+$(obj)/speakupmap.h: $(obj)/speakupmap.map $(obj)/genmap
+	$(call cmd,genmap)
+
+$(obj)/main.o: $(obj)/speakupmap.h
drivers/accessibility/speakup/genmap.c new file +162 -0

162 lines not on this page · raw message

drivers/accessibility/speakup/makemapdata.c new file +125 -0

125 lines not on this page · raw message

drivers/accessibility/speakup/speakupmap.h deleted +0 -66

66 lines not on this page · raw message

drivers/accessibility/speakup/utils.h new file +99 -0

99 lines not on this page · raw message

drivers/accessibility/speakup/.gitignore new file +4 -0
@@ -0,0 +1,4 @@
+/makemapdata
+/mapdata.h
+/genmap
+/speakupmap.h