priliz riedke riadkovanie PRE bloku

Sekcia: Ostatné 01.02.2007 | 17:07
Avatar nahnevaný mladý muž gNewSense  Používateľ
Nezda sa vam ze v tomto fore je riadkovanie trochu zbytocne riedke?


int
main (int argc, char **argv)
{
char *name;
initialize_main (&argc, &argv);
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
usage (EXIT_FAILURE);
if (argc < optind + 1)
{
error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
if (optind + 2 < argc)
{
error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
usage (EXIT_FAILURE);
}
name = base_name (argv[optind]);
strip_trailing_slashes (name);
/* Per POSIX, `basename // /' must return `//' on platforms with
distinct //. On platforms with drive letters, this generalizes
to making `basename c: :' return `c:'. This rule is captured by
skipping suffix stripping if base_name returned an absolute path
or a drive letter (only possible if name is a file-system
root). */
if (argc == optind + 2 && IS_RELATIVE_FILE_NAME (name)
&& ! FILE_SYSTEM_PREFIX_LEN (name))
remove_suffix (name, argv[optind + 1]);
puts (name);
free (name);
exit (EXIT_SUCCESS);
}
    • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 19:18
      Avatar pe3k Debian, Feisty  Používateľ
      zda :)
    • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 19:49
      WaSaTy   Návštevník
      zavisi od toho ci pouzijes tag pre alebo code, kazdy je urceny na nieco ine, takze ???
      • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 19:54
        Avatar uid0 Debian  Používateľ
        ja by som na kod pouzival pre, pretoze mi zachova medzery a taby...
        Debian. apt-get into it…
    • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 19:56
      Avatar uid0 Debian  Používateľ
      mlady muz, tebe sa vazne paci GNU indentation? ble
      Debian. apt-get into it…
      • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 21:49
        Avatar nahnevaný mladý muž gNewSense  Používateľ
        Asi ta sklamem ale to nieje moj kod. Je to kod basename z GNU Coreutils takze je pochopitelne ze v GNU pouzivaju GNU indent ;).

        Pouzil som to len ako priklad lebo 5 minut pred tym postom som do coreutils hlasil bug v basename.

        int
        main (int argc, char **argv)
        {
          char *name;
          initialize_main (&argc, &argv);
          program_name = argv[0];
          setlocale (LC_ALL, "");
          bindtextdomain (PACKAGE, LOCALEDIR);
          textdomain (PACKAGE);
          atexit (close_stdout);
          parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
        		      usage, AUTHORS, (char const *) NULL);
          if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
            usage (EXIT_FAILURE);
          if (argc < optind + 1)
            {
              error (0, 0, _("missing operand"));
              usage (EXIT_FAILURE);
            }
          if (optind + 2 < argc)
            {
              error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
              usage (EXIT_FAILURE);
            }
          name = base_name (argv[optind]);
          strip_trailing_slashes (name);
          /* Per POSIX, `basename // /' must return `//' on platforms with
             distinct //.  On platforms with drive letters, this generalizes
             to making `basename c: :' return `c:'.  This rule is captured by
             skipping suffix stripping if base_name returned an absolute path
             or a drive letter (only possible if name is a file-system
             root).  */
          if (argc == optind + 2 && IS_RELATIVE_FILE_NAME (name)
              && ! FILE_SYSTEM_PREFIX_LEN (name))
            remove_suffix (name, argv[optind + 1]);
          puts (name);
          free (name);
          exit (EXIT_SUCCESS);
        } 
        


        Zda sa ze to funguje. Vdaka.
    • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 19:57
      Avatar Miroslav Bendík Gentoo  Administrátor
      Moja chyba, opravene.
      • Re: priliz riedke riadkovanie PRE bloku 01.02.2007 | 20:53
        Avatar uid0 Debian  Používateľ
        radujme sa, konecne fungujuce pre....
        Debian. apt-get into it…