Use spaces for indentation, not tabs.
[gnulib.git] / lib / uniwbrk / ulc-wordbreaks.c
index cb6e131..9869bfb 100644 (file)
@@ -49,60 +49,60 @@ ulc_wordbreaks (const char *s, size_t n, char *p)
       const char *encoding = locale_charset ();
 
       if (is_utf8_encoding (encoding))
-       u8_wordbreaks ((const uint8_t *) s, n, p);
+        u8_wordbreaks ((const uint8_t *) s, n, p);
       else
-       {
-         /* Convert the string to UTF-8 and build a translation table
-            from offsets into s to offsets into the translated string.  */
-         size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
-
-         if (offsets != NULL)
-           {
-             uint8_t *t;
-             size_t m;
-
-             t = u8_conv_from_encoding (encoding, iconveh_question_mark,
-                                        s, n, offsets, NULL, &m);
-             if (t != NULL)
-               {
-                 char *q = (char *) (m > 0 ? malloc (m) : NULL);
-
-                 if (m == 0 || q != NULL)
-                   {
-                     size_t i;
-
-                     /* Determine the word breaks of the UTF-8 string.  */
-                     u8_wordbreaks (t, m, q);
-
-                     /* Translate the result back to the original string.  */
-                     memset (p, 0, n);
-                     for (i = 0; i < n; i++)
-                       if (offsets[i] != (size_t)(-1))
-                         p[i] = q[offsets[i]];
-
-                     free (q);
-                     free (t);
-                     free (offsets);
-                     return;
-                   }
-                 free (t);
-               }
-             free (offsets);
-           }
-
-         /* Impossible to convert.  */
+        {
+          /* Convert the string to UTF-8 and build a translation table
+             from offsets into s to offsets into the translated string.  */
+          size_t *offsets = (size_t *) malloc (n * sizeof (size_t));
+
+          if (offsets != NULL)
+            {
+              uint8_t *t;
+              size_t m;
+
+              t = u8_conv_from_encoding (encoding, iconveh_question_mark,
+                                         s, n, offsets, NULL, &m);
+              if (t != NULL)
+                {
+                  char *q = (char *) (m > 0 ? malloc (m) : NULL);
+
+                  if (m == 0 || q != NULL)
+                    {
+                      size_t i;
+
+                      /* Determine the word breaks of the UTF-8 string.  */
+                      u8_wordbreaks (t, m, q);
+
+                      /* Translate the result back to the original string.  */
+                      memset (p, 0, n);
+                      for (i = 0; i < n; i++)
+                        if (offsets[i] != (size_t)(-1))
+                          p[i] = q[offsets[i]];
+
+                      free (q);
+                      free (t);
+                      free (offsets);
+                      return;
+                    }
+                  free (t);
+                }
+              free (offsets);
+            }
+
+          /* Impossible to convert.  */
 #if C_CTYPE_ASCII
-         if (is_all_ascii (s, n))
-           {
-             /* ASCII is a subset of UTF-8.  */
-             u8_wordbreaks ((const uint8_t *) s, n, p);
-             return;
-           }
+          if (is_all_ascii (s, n))
+            {
+              /* ASCII is a subset of UTF-8.  */
+              u8_wordbreaks ((const uint8_t *) s, n, p);
+              return;
+            }
 #endif
-         /* We have a non-ASCII string and cannot convert it.
-            Don't produce any word breaks.  */
-         memset (p, 0, n);
-       }
+          /* We have a non-ASCII string and cannot convert it.
+             Don't produce any word breaks.  */
+          memset (p, 0, n);
+        }
     }
 }
 
@@ -127,28 +127,28 @@ read_file (FILE *stream)
   while (! feof (stream))
     {
       if (size + BUFSIZE > alloc)
-       {
-         alloc = alloc + alloc / 2;
-         if (alloc < size + BUFSIZE)
-           alloc = size + BUFSIZE;
-         buf = realloc (buf, alloc);
-         if (buf == NULL)
-           {
-             fprintf (stderr, "out of memory\n");
-             exit (1);
-           }
-       }
+        {
+          alloc = alloc + alloc / 2;
+          if (alloc < size + BUFSIZE)
+            alloc = size + BUFSIZE;
+          buf = realloc (buf, alloc);
+          if (buf == NULL)
+            {
+              fprintf (stderr, "out of memory\n");
+              exit (1);
+            }
+        }
       count = fread (buf + size, 1, BUFSIZE, stream);
       if (count == 0)
-       {
-         if (ferror (stream))
-           {
-             perror ("fread");
-             exit (1);
-           }
-       }
+        {
+          if (ferror (stream))
+            {
+              perror ("fread");
+              exit (1);
+            }
+        }
       else
-       size += count;
+        size += count;
     }
   buf = realloc (buf, size + 1);
   if (buf == NULL)
@@ -176,19 +176,19 @@ main (int argc, char * argv[])
       ulc_wordbreaks (input, length, breaks);
 
       for (i = 0; i < length; i++)
-       {
-         switch (breaks[i])
-           {
-           case 1:
-             putc ('|', stdout);
-             break;
-           case 0:
-             break;
-           default:
-             abort ();
-           }
-         putc (input[i], stdout);
-       }
+        {
+          switch (breaks[i])
+            {
+            case 1:
+              putc ('|', stdout);
+              break;
+            case 0:
+              break;
+            default:
+              abort ();
+            }
+          putc (input[i], stdout);
+        }
 
       free (breaks);