This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 02/14] S390: Mention s390-specific gconv-modues before common ones.


This patch changes the order in gconv-modules. Now the s390-specific
modules are mentioned before the common ones, because these modules
aren't used in all possible conversions. E.g. the converting-step from
INTERNAL to UTF-16 used the common UTF-16.so module instead of
UTF16_UTF32_Z9.so.

The awk script is parsing the source gconv-modules file and copies it
line by line. The s390 modules are emitted between the header-comments
and the first common-code-module.

ChangeLog:

	* sysdeps/s390/s390-64/Makefile ($(objpfx)gconv-modules-s390):
	Mention s390-specific gconv-modules before common ones.
---
 sysdeps/s390/s390-64/Makefile | 82 ++++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 33 deletions(-)

diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile
index de249a7..d1ee59d 100644
--- a/sysdeps/s390/s390-64/Makefile
+++ b/sysdeps/s390/s390-64/Makefile
@@ -40,39 +40,55 @@ $(inst_gconvdir)/%.so: $(objpfx)%.so $(+force)
 	$(do-install-program)
 
 $(objpfx)gconv-modules-s390: gconv-modules
-	cp $< $@
-	echo >> $@
-	echo "# S/390 hardware accelerated modules" >> $@
-	echo -n "module	ISO-8859-1//		IBM037//	" >> $@
-	echo "	ISO-8859-1_CP037_Z900	1" >> $@
-	echo -n "module	IBM037//		ISO-8859-1//	" >> $@
-	echo "	ISO-8859-1_CP037_Z900	1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-32//	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		ISO-10646/UTF8/	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-32BE//	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		UTF-32//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		UTF-16//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	INTERNAL		UTF-16//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		UTF-16BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	INTERNAL		UTF-16BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		UTF-32BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		INTERNAL	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		ISO-10646/UTF8/	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-16//	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-16BE//	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
+	${AWK} 'BEGIN { emitted = 0 } \
+	emitted || NF == 0 || $$1 ~ /^#/ { print; next; } \
+	!emitted { emit_s390_modules(); emitted = 1; print; } \
+	function emit_s390_modules() { \
+	  # Emit header line. \
+	  print "# S/390 hardware accelerated modules"; \
+	  print_val("#", 8); \
+	  print_val("from", 24); \
+	  print_val("to", 24); \
+	  print_val("module", 24); \
+	  printf "cost\n"; \
+	  # Emit s390-specific modules. \
+	  modul("ISO-8859-1//", "IBM037//", "ISO-8859-1_CP037_Z900"); \
+	  modul("IBM037//", "ISO-8859-1//", "ISO-8859-1_CP037_Z900"); \
+	  modul("ISO-10646/UTF8/", "UTF-32//", "UTF8_UTF32_Z9"); \
+	  modul("UTF-32BE//", "ISO-10646/UTF8/", "UTF8_UTF32_Z9"); \
+	  modul("ISO-10646/UTF8/", "UTF-32BE//", "UTF8_UTF32_Z9"); \
+	  modul("UTF-16BE//", "UTF-32//", "UTF16_UTF32_Z9"); \
+	  modul("UTF-32BE//", "UTF-16//", "UTF16_UTF32_Z9"); \
+	  modul("INTERNAL", "UTF-16//", "UTF16_UTF32_Z9"); \
+	  modul("UTF-32BE//", "UTF-16BE//", "UTF16_UTF32_Z9"); \
+	  modul("INTERNAL", "UTF-16BE//", "UTF16_UTF32_Z9"); \
+	  modul("UTF-16BE//", "UTF-32BE//", "UTF16_UTF32_Z9"); \
+	  modul("UTF-16BE//", "INTERNAL", "UTF16_UTF32_Z9"); \
+	  modul("UTF-16BE//", "ISO-10646/UTF8/", "UTF8_UTF16_Z9"); \
+	  modul("ISO-10646/UTF8/", "UTF-16//", "UTF8_UTF16_Z9"); \
+	  modul("ISO-10646/UTF8/", "UTF-16BE//", "UTF8_UTF16_Z9"); \
+	  printf "\n# Default glibc modules\n"; \
+	} \
+	function modul(from, to, file, cost) { \
+	  print_val("module", 8); \
+	  print_val(from, 24); \
+	  print_val(to, 24); \
+	  print_val(file, 24); \
+	  if (cost == 0) cost = 1; \
+	  printf "%d\n", cost; \
+	} \
+	function print_val(val, width) { \
+	  # Emit value followed by tabs. \
+	  printf "%s", val; \
+	  len = length(val); \
+	  if (len < width) { \
+	    len = width - len; \
+	    nr_tabs = len / 8; \
+	    if (len % 8 != 0) nr_tabs++; \
+	  } \
+	  else nr_tabs = 1; \
+	  for (i = 1; i <= nr_tabs; i++) printf "\t"; \
+	}' < $< > $@
 
 GCONV_MODULES = gconv-modules-s390
 
-- 
2.3.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]