/* dirname -- strip suffix from file name                                       This is the dirname utility
                                                                                
   Copyright (C) 1990-2018 Free Software Foundation, Inc.                       
                                                                                
   This program is free software: you can redistribute it and/or modify         
   it under the terms of the GNU General Public License as published by         
   the Free Software Foundation, either version 3 of the License, or            
   (at your option) any later version.                                          
                                                                                
   This program is distributed in the hope that it will be useful,              
   but WITHOUT ANY WARRANTY; without even the implied warranty of               
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                
   GNU General Public License for more details.                                 
                                                                                
   You should have received a copy of the GNU General Public License            
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */   The GNUv3 license
                                                                                
/* Written by David MacKenzie and Jim Meyering. */                              
                                                                                
#include <config.h>                                                             Provides system specific information
#include <getopt.h>                                                             ...!includes auto-comment...
#include <stdio.h>                                                              Provides standard I/O capability
#include <sys/types.h>                                                          Provides system data types
                                                                                
#include "system.h"                                                             ...!includes auto-comment...
#include "error.h"                                                              ...!includes auto-comment...
                                                                                
/* The official name of this program (e.g., no 'g' prefix).  */                 
#define PROGRAM_NAME "dirname"                                                  Line 29
                                                                                
#define AUTHORS \                                                               Line 31
  proper_name ("David MacKenzie"), \                                            Line 32
  proper_name ("Jim Meyering")                                                  Line 33
                                                                                
static struct option const longopts[] =                                         Line 35
{                                                                               
  {"zero", no_argument, NULL, 'z'},                                             Line 37
  {GETOPT_HELP_OPTION_DECL},                                                    Line 38
  {GETOPT_VERSION_OPTION_DECL},                                                 Line 39
  {NULL, 0, NULL, 0}                                                            Line 40
};                                                                              Block 1
                                                                                
void                                                                            Line 43
usage (int status)                                                              Line 44
{                                                                               
  if (status != EXIT_SUCCESS)                                                   Line 46
    emit_try_help ();                                                           ...!common auto-comment...
  else                                                                          Line 48
    {                                                                           
      printf (_("\                                                              Line 50
Usage: %s [OPTION] NAME...\n\                                                   Line 51
"),                                                                             Line 52
              program_name);                                                    Line 53
      fputs (_("\                                                               Line 54
Output each NAME with its last non-slash component and trailing slashes\n\      Line 55
removed; if NAME contains no /'s, output '.' (meaning the current directory).\n\Line 56
\n\                                                                             
"), stdout);                                                                    Line 58
      fputs (_("\                                                               Line 59
  -z, --zero     end each output line with NUL, not newline\n\                  Line 60
"), stdout);                                                                    Line 61
      fputs (HELP_OPTION_DESCRIPTION, stdout);                                  Line 62
      fputs (VERSION_OPTION_DESCRIPTION, stdout);                               Line 63
      printf (_("\                                                              Line 64
\n\                                                                             
Examples:\n\                                                                    Line 66
  %s /usr/bin/          -> \"/usr\"\n\                                          Line 67
  %s dir1/str dir2/str  -> \"dir1\" followed by \"dir2\"\n\                     Line 68
  %s stdio.h            -> \".\"\n\                                             Provides standard I/O capability
"),                                                                             Line 70
              program_name, program_name, program_name);                        Line 71
      emit_ancillary_info (PROGRAM_NAME);                                       Line 72
    }                                                                           
  exit (status);                                                                Line 74
}                                                                               Block 2
                                                                                
int                                                                             
main (int argc, char **argv)                                                    Line 78
{                                                                               
  static char const dot = '.';                                                  Line 80
  bool use_nuls = false;                                                        Line 81
  char const *result;                                                           Line 82
  size_t len;                                                                   Line 83
                                                                                
  initialize_main (&argc, &argv);                                               VMS-specific entry point handling wildcard expansion
  set_program_name (argv[0]);                                                   Retains program name and discards path
  setlocale (LC_ALL, "");                                                       Sets up internationalization (i18n)
  bindtextdomain (PACKAGE, LOCALEDIR);                                          Assigns i18n directorySets text domain for _() [gettext()] function
  textdomain (PACKAGE);                                                         Sets text domain for _() [gettext()] function
                                                                                
  atexit (close_stdout);                                                        Close stdout on exit (see gnulib)
                                                                                
  while (true)                                                                  Line 93
    {                                                                           
      int c = getopt_long (argc, argv, "z", longopts, NULL);                    Line 95
                                                                                
      if (c == -1)                                                              Line 97
        break;                                                                  Line 98
                                                                                
      switch (c)                                                                Line 100
        {                                                                       
        case 'z':                                                               Line 102
          use_nuls = true;                                                      Line 103
          break;                                                                Line 104
                                                                                
        case_GETOPT_HELP_CHAR;                                                  Line 106
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);                       Line 107
                                                                                
        default:                                                                Line 109
          usage (EXIT_FAILURE);                                                 Line 110
        }                                                                       
    }                                                                           
                                                                                
  if (argc < optind + 1)                                                        Line 114
    {                                                                           
      error (0, 0, _("missing operand"));                                       Line 116
      usage (EXIT_FAILURE);                                                     Line 117
    }                                                                           
                                                                                
  for (; optind < argc; optind++)                                               Line 120
    {                                                                           
      result = argv[optind];                                                    Line 122
      len = dir_len (result);                                                   Line 123
                                                                                
      if (! len)                                                                Line 125
        {                                                                       
          result = ˙                                                        Line 127
          len = 1;                                                              Line 128
        }                                                                       
                                                                                
      fwrite (result, 1, len, stdout);                                          Line 131...!syscalls auto-comment...
      putchar (use_nuls ? '\0' :'\n');                                          Line 132
    }                                                                           
                                                                                
  return EXIT_SUCCESS;                                                          Line 135
}                                                                               Block 3