Introduction
Introduction Statistics Contact Development Disclaimer Help
Refactor keyboard file load. - sam - An updated version of the sam text editor.
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 4ee9c949e17d842112a6ebf9508efb13b0b29870
parent cead875fb4c7df577eb3d215b2d21a290423c5a2
Author: Rob King <[email protected]>
Date: Thu, 11 Aug 2016 23:31:35 -0500
Refactor keyboard file load.
Diffstat:
libXg/latin1.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/libXg/latin1.c b/libXg/latin1.c
@@ -236,6 +236,19 @@ freelatin(void)
}
void
+addlatin(char c0, char c1, int l)
+{
+ static int i = 0;
+
+ if (mappings && i < MAPPING_MAX){
+ mappings[i].c[0] = c0;
+ mappings[i].c[1] = c1;
+ mappings[i].l = l;
+ i++;
+ }
+}
+
+void
initlatin(void)
{
mappings = calloc(MAPPING_MAX + 1, sizeof(struct latin));
@@ -252,17 +265,10 @@ initlatin(void)
if (!keyboard)
return;
- int j = 0;
- while (j < MAPPING_MAX){
- int count = fscanf(keyboard, " %c%c %hx%*[^\n]\n", &(mappings[…
- if (count == 3)
- j++;
- else if (count == EOF){
- memset(&(mappings[j]), 0, sizeof(struct latin));
- break;
- } else
- memset(&(mappings[j]), 0, sizeof(struct latin));
- }
+ unsigned char c0, c1;
+ unsigned short l;
+ while (fscanf(keyboard, " %c%c %hx%*[^\n]\n", &c0, &c1, &l) == 3)
+ addlatin(c0, c1, l);
fclose(keyboard);
}
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.