From daa72bf188b2f630ffd1f8291abed65efce42640 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 7 Jul 2016 10:51:58 -0400
Subject: [PATCH 21/25] FIXME: cleanups

---
 libcpp/charset.c | 60 ++++++++++++++------------------------------------------
 1 file changed, 15 insertions(+), 45 deletions(-)

diff --git a/libcpp/charset.c b/libcpp/charset.c
index ad40860..b135c58 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -99,7 +99,6 @@ struct _cpp_strbuf
   uchar *text;
   size_t asize;
   size_t len;
-  //cpp_string_location loc;
 };
 
 /* This is enough to hold any string that fits on a single 80-column
@@ -455,7 +454,6 @@ static inline bool
 conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
 					     uchar **, size_t *),
 		 iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to)
-//cpp_string_location_reader *loc_reader)
 {
   const uchar *inbuf;
   uchar *outbuf;
@@ -470,20 +468,8 @@ conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
   for (;;)
     {
       do
-	{
-	  //	  size_t old_outbytesleft = outbytesleft;
-	  rval = one_conversion (cd, &inbuf, &inbytesleft,
-				 &outbuf, &outbytesleft);
-#if 0
-	  if (loc_reader)
-	    {
-	      size_t bytes_written = outbytesleft - old_outbytesleft;
-	      to->loc.add_char_at (loc_reader->get_next (),
-				   bytes_written,
-				   loc_reader->get_line_maps ());
-	    }
-#endif
-	}
+	rval = one_conversion (cd, &inbuf, &inbytesleft,
+			       &outbuf, &outbytesleft);
       while (inbytesleft && !rval);
 
       if (__builtin_expect (inbytesleft == 0, 1))
@@ -508,8 +494,7 @@ conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
 /* These functions convert entire strings between character sets.
    They all have the signature
 
-   bool (*)(iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to,
-            cpp_string_location_reader *loc_reader, bool single_item);
+   bool (*)(iconv_t cd, const uchar *from, size_t flen, struct _cpp_strbuf *to);
 
    The input string FROM is converted as specified by the function
    name plus the iconv descriptor CD (which may be fake), and the
@@ -518,42 +503,36 @@ conversion_loop (int (*const one_conversion)(iconv_t, const uchar **, size_t *,
 /* These four use the custom conversion code above.  */
 static bool
 convert_utf8_utf16 (iconv_t cd, const uchar *from, size_t flen,
-		    struct _cpp_strbuf *to)//, cpp_string_location_reader *loc_reader,
-//bool single_item ATTRIBUTE_UNUSED)
+		    struct _cpp_strbuf *to)
 {
-  return conversion_loop (one_utf8_to_utf16, cd, from, flen, to);//, loc_reader);
+  return conversion_loop (one_utf8_to_utf16, cd, from, flen, to);
 }
 
 static bool
 convert_utf8_utf32 (iconv_t cd, const uchar *from, size_t flen,
-		    struct _cpp_strbuf *to)//, cpp_string_location_reader *loc_reader,
-//bool single_item ATTRIBUTE_UNUSED)
+		    struct _cpp_strbuf *to)
 {
-  return conversion_loop (one_utf8_to_utf32, cd, from, flen, to);//, loc_reader);
+  return conversion_loop (one_utf8_to_utf32, cd, from, flen, to);
 }
 
 static bool
 convert_utf16_utf8 (iconv_t cd, const uchar *from, size_t flen,
-		    struct _cpp_strbuf *to)//, cpp_string_location_reader *loc_reader,
-//bool single_item ATTRIBUTE_UNUSED)
+		    struct _cpp_strbuf *to)
 {
-  return conversion_loop (one_utf16_to_utf8, cd, from, flen, to);//, loc_reader);
+  return conversion_loop (one_utf16_to_utf8, cd, from, flen, to);
 }
 
 static bool
 convert_utf32_utf8 (iconv_t cd, const uchar *from, size_t flen,
-		    struct _cpp_strbuf *to)//, cpp_string_location_reader *loc_reader,
-//bool single_item ATTRIBUTE_UNUSED)
+		    struct _cpp_strbuf *to)
 {
-  return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);//, loc_reader);
+  return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);
 }
 
 /* Identity conversion, used when we have no alternative.  */
 static bool
 convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
 		       const uchar *from, size_t flen, struct _cpp_strbuf *to)
-//cpp_string_location_reader *loc_reader,
-//bool single_item)
 {
   if (to->len + flen > to->asize)
     {
@@ -563,12 +542,6 @@ convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
     }
   memcpy (to->text + to->len, from, flen);
   to->len += flen;
-#if 0
-  if (single_item)
-    to->loc.add_n_chars_at (1, flen, loc_reader);
-  else
-    to->loc.add_n_chars_at (flen, 1, loc_reader);
-#endif
   return true;
 }
 
@@ -586,9 +559,7 @@ convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
 
 static bool
 convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
-		     struct _cpp_strbuf *to)//,
-//cpp_string_location_reader */*loc_reader*/,
-//bool single_item ATTRIBUTE_UNUSED)
+		     struct _cpp_strbuf *to)
 {
   ICONV_CONST char *inbuf;
   char *outbuf;
@@ -635,8 +606,8 @@ convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
 /* Arrange for the above custom conversion logic to be used automatically
    when conversion between a suitable pair of character sets is requested.  */
 
-#define APPLY_CONVERSION(CONVERTER, FROM, FLEN, TO) /*, LOC_READER, SINGLE_ITEM) \*/ \
-  CONVERTER.func (CONVERTER.cd, FROM, FLEN, TO)//, LOC_READER, SINGLE_ITEM)
+#define APPLY_CONVERSION(CONVERTER, FROM, FLEN, TO) \
+   CONVERTER.func (CONVERTER.cd, FROM, FLEN, TO)
 
 struct cpp_conversion
 {
@@ -821,9 +792,8 @@ cpp_host_to_exec_charset (cpp_reader *pfile, cppchar_t c)
   tbuf.asize = 1;
   tbuf.text = XNEWVEC (uchar, tbuf.asize);
   tbuf.len = 0;
-  //tbuf.loc.init ();
 
-  if (!APPLY_CONVERSION (pfile->narrow_cset_desc, sbuf, 1, &tbuf))//, NULL, true))
+  if (!APPLY_CONVERSION (pfile->narrow_cset_desc, sbuf, 1, &tbuf))
     {
       cpp_errno (pfile, CPP_DL_ICE, "converting to execution character set");
       return 0;
-- 
1.8.5.3

