亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sort.c

?? Linux.Programming.by example 的源代碼絕對經典
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* sort - sort lines of text (with all kinds of options).   Copyright (C) 88, 1991-2002 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 2, 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, write to the Free Software   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   Written December 1988 by Mike Haertel.   The author may be reached (Email) at the address mike@gnu.ai.mit.edu,   or (US mail) as Mike Haertel c/o Free Software Foundation.   豶n E. Hansen added NLS support in 1997.  */#include <config.h>#include <getopt.h>#include <sys/types.h>#include <signal.h>#include <stdio.h>#include <assert.h>#include "system.h"#include "long-options.h"#include "error.h"#include "hard-locale.h"#include "inttostr.h"#include "physmem.h"#include "posixver.h"#include "stdio-safer.h"#include "xmemcoll.h"#include "xstrtol.h"#if HAVE_SYS_RESOURCE_H# include <sys/resource.h>#endif#ifndef RLIMIT_DATAstruct rlimit { size_t rlim_cur; };# define getrlimit(Resource, Rlp) (-1)#endif/* The official name of this program (e.g., no `g' prefix).  */#define PROGRAM_NAME "sort"#define AUTHORS N_ ("Mike Haertel and Paul Eggert")#if HAVE_LANGINFO_CODESET# include <langinfo.h>#endif#ifndef SA_NOCLDSTOP# define sigprocmask(How, Set, Oset) /* empty */# define sigset_t int#endif#ifndef STDC_HEADERSdouble strtod ();#endif/* Undefine, to avoid warning about redefinition on some systems.  *//* FIXME: Remove these: use MIN/MAX from sys2.h.  */#undef min#define min(a, b) ((a) < (b) ? (a) : (b))#undef max#define max(a, b) ((a) > (b) ? (a) : (b))#define UCHAR_LIM (UCHAR_MAX + 1)#define UCHAR(c) ((unsigned char) (c))#ifndef DEFAULT_TMPDIR# define DEFAULT_TMPDIR "/tmp"#endif/* Use this as exit status in case of error, not EXIT_FAILURE.  This   is necessary because EXIT_FAILURE is usually 1 and POSIX requires   that sort exit with status 1 IFF invoked with -c and the input is   not properly sorted.  Any other irregular exit must exit with a   status code greater than 1.  */#define SORT_FAILURE 2#define SORT_OUT_OF_ORDER 1#define C_DECIMAL_POINT '.'#define NEGATION_SIGN   '-'#define NUMERIC_ZERO    '0'#if HAVE_SETLOCALEstatic char decimal_point;static int th_sep; /* if CHAR_MAX + 1, then there is no thousands separator *//* Nonzero if the corresponding locales are hard.  */static int hard_LC_COLLATE;# if HAVE_NL_LANGINFOstatic int hard_LC_TIME;# endif# define IS_THOUSANDS_SEP(x) ((x) == th_sep)#else# define decimal_point C_DECIMAL_POINT# define IS_THOUSANDS_SEP(x) 0#endif#define NONZERO(x) (x != 0)/* The kind of blanks for '-b' to skip in various options. */enum blanktype { bl_start, bl_end, bl_both };/* The character marking end of line. Default to \n. */static int eolchar = '\n';/* Lines are held in core as counted strings. */struct line{  char *text;			/* Text of the line. */  size_t length;		/* Length including final newline. */  char *keybeg;			/* Start of first key. */  char *keylim;			/* Limit of first key. */};/* Input buffers. */struct buffer{  char *buf;			/* Dynamically allocated buffer,				   partitioned into 3 regions:				   - input data;				   - unused area;				   - an array of lines, in reverse order.  */  size_t used;			/* Number of bytes used for input data.  */  size_t nlines;		/* Number of lines in the line array.  */  size_t alloc;			/* Number of bytes allocated. */  size_t left;			/* Number of bytes left from previous reads. */  size_t line_bytes;		/* Number of bytes to reserve for each line. */  int eof;			/* An EOF has been read.  */};struct keyfield{  size_t sword;			/* Zero-origin 'word' to start at. */  size_t schar;			/* Additional characters to skip. */  int skipsblanks;		/* Skip leading white space at start. */  size_t eword;			/* Zero-origin first word after field. */  size_t echar;			/* Additional characters in field. */  int skipeblanks;		/* Skip trailing white space at finish. */  int *ignore;			/* Boolean array of characters to ignore. */  char *translate;		/* Translation applied to characters. */  int numeric;			/* Flag for numeric comparison.  Handle				   strings of digits with optional decimal				   point, but no exponential notation. */  int general_numeric;		/* Flag for general, numeric comparison.				   Handle numbers in exponential notation. */  int month;			/* Flag for comparison by month name. */  int reverse;			/* Reverse the sense of comparison. */  struct keyfield *next;	/* Next keyfield to try. */};struct month{  char *name;  int val;};/* The name this program was run with. */char *program_name;/* FIXME: None of these tables work with multibyte character sets.   Also, there are many other bugs when handling multibyte characters,   or even unibyte encodings where line boundaries are not in the   initial shift state.  One way to fix this is to rewrite `sort' to   use wide characters internally, but doing this with good   performance is a bit tricky.  *//* Table of white space. */static int blanks[UCHAR_LIM];/* Table of non-printing characters. */static int nonprinting[UCHAR_LIM];/* Table of non-dictionary characters (not letters, digits, or blanks). */static int nondictionary[UCHAR_LIM];/* Translation table folding lower case to upper.  */static char fold_toupper[UCHAR_LIM];#define MONTHS_PER_YEAR 12/* Table mapping month names to integers.   Alphabetic order allows binary search. */static struct month monthtab[] ={  {"APR", 4},  {"AUG", 8},  {"DEC", 12},  {"FEB", 2},  {"JAN", 1},  {"JUL", 7},  {"JUN", 6},  {"MAR", 3},  {"MAY", 5},  {"NOV", 11},  {"OCT", 10},  {"SEP", 9}};/* During the merge phase, the number of files to merge at once. */#define NMERGE 16/* Minimum size for a merge or check buffer.  */#define MIN_MERGE_BUFFER_SIZE (2 + sizeof (struct line))/* Minimum sort size; the code might not work with smaller sizes.  */#define MIN_SORT_SIZE (NMERGE * MIN_MERGE_BUFFER_SIZE)/* The number of bytes needed for a merge or check buffer, which can   function relatively efficiently even if it holds only one line.  If   a longer line is seen, this value is increased.  */static size_t merge_buffer_size = MAX (MIN_MERGE_BUFFER_SIZE, 256 * 1024);/* The approximate maximum number of bytes of main memory to use, as   specified by the user.  Zero if the user has not specified a size.  */static size_t sort_size;/* The guessed size for non-regular files.  */#define INPUT_FILE_SIZE_GUESS (1024 * 1024)/* Array of directory names in which any temporary files are to be created. */static char const **temp_dirs;/* Number of temporary directory names used.  */static size_t temp_dir_count;/* Number of allocated slots in temp_dirs.  */static size_t temp_dir_alloc;/* Flag to reverse the order of all comparisons. */static int reverse;/* Flag for stable sort.  This turns off the last ditch bytewise   comparison of lines, and instead leaves lines in the same order   they were read if all keys compare equal.  */static int stable;/* Tab character separating fields.  If NUL, then fields are separated   by the empty string between a non-whitespace character and a whitespace   character. */static char tab;/* Flag to remove consecutive duplicate lines from the output.   Only the last of a sequence of equal lines will be output. */static int unique;/* Nonzero if any of the input files are the standard input. */static int have_read_stdin;/* List of key field comparisons to be tried.  */static struct keyfield *keylist;voidusage (int status){  if (status != 0)    fprintf (stderr, _("Try `%s --help' for more information.\n"),	     program_name);  else    {      printf (_("\Usage: %s [OPTION]... [FILE]...\n\"),	      program_name);      fputs (_("\Write sorted concatenation of all FILE(s) to standard output.\n\\n\Ordering options:\n\\n\"), stdout);      fputs (_("\Mandatory arguments to long options are mandatory for short options too.\n\"), stdout);      fputs (_("\  -b, --ignore-leading-blanks ignore leading blanks\n\  -d, --dictionary-order      consider only blanks and alphanumeric characters\n\  -f, --ignore-case           fold lower case to upper case characters\n\"), stdout);      fputs (_("\  -g, --general-numeric-sort  compare according to general numerical value\n\  -i, --ignore-nonprinting    consider only printable characters\n\  -M, --month-sort            compare (unknown) < `JAN' < ... < `DEC'\n\  -n, --numeric-sort          compare according to string numerical value\n\  -r, --reverse               reverse the result of comparisons\n\\n\"), stdout);      fputs (_("\Other options:\n\\n\  -c, --check               check whether input is sorted; do not sort\n\  -k, --key=POS1[,POS2]     start a key at POS1, end it at POS 2 (origin 1)\n\  -m, --merge               merge already sorted files; do not sort\n\  -o, --output=FILE         write result to FILE instead of standard output\n\  -s, --stable              stabilize sort by disabling last-resort comparison\n\  -S, --buffer-size=SIZE    use SIZE for main memory buffer\n\"), stdout);      printf (_("\  -t, --field-separator=SEP use SEP instead of non- to whitespace transition\n\  -T, --temporary-directory=DIR  use DIR for temporaries, not $TMPDIR or %s\n\                              multiple options specify multiple directories\n\  -u, --unique              with -c: check for strict ordering\n\                              otherwise: output only the first of an equal run\n\"), DEFAULT_TMPDIR);      fputs (_("\  -z, --zero-terminated     end lines with 0 byte, not newline\n\"), stdout);      fputs (HELP_OPTION_DESCRIPTION, stdout);      fputs (VERSION_OPTION_DESCRIPTION, stdout);      fputs (_("\\n\POS is F[.C][OPTS], where F is the field number and C the character position\n\in the field.  OPTS is one or more single-letter ordering options, which\n\override global ordering options for that key.  If no key is given, use the\n\entire line as the key.\n\\n\SIZE may be followed by the following multiplicative suffixes:\n\"), stdout);      fputs (_("\% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.\n\\n\With no FILE, or when FILE is -, read standard input.\n\\n\*** WARNING ***\n\The locale specified by the environment affects sort order.\n\Set LC_ALL=C to get the traditional sort order that uses\n\native byte values.\n\"), stdout );      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);    }  /* Don't use EXIT_FAILURE here in case it is defined to be 1.     POSIX requires that sort return 1 IFF invoked with -c and     the input is not properly sorted.  */  assert (status == 0 || status == SORT_FAILURE);  exit (status);}#define COMMON_SHORT_OPTIONS "-bcdfgik:mMno:rsS:t:T:uz"static struct option const long_options[] ={  {"ignore-leading-blanks", no_argument, NULL, 'b'},  {"check", no_argument, NULL, 'c'},  {"dictionary-order", no_argument, NULL, 'd'},  {"ignore-case", no_argument, NULL, 'f'},  {"general-numeric-sort", no_argument, NULL, 'g'},  {"ignore-nonprinting", no_argument, NULL, 'i'},  {"key", required_argument, NULL, 'k'},  {"merge", no_argument, NULL, 'm'},  {"month-sort", no_argument, NULL, 'M'},  {"numeric-sort", no_argument, NULL, 'n'},  {"output", required_argument, NULL, 'o'},  {"reverse", no_argument, NULL, 'r'},  {"stable", no_argument, NULL, 's'},  {"buffer-size", required_argument, NULL, 'S'},  {"field-separator", required_argument, NULL, 't'},  {"temporary-directory", required_argument, NULL, 'T'},  {"unique", no_argument, NULL, 'u'},  {"zero-terminated", no_argument, NULL, 'z'},  {GETOPT_HELP_OPTION_DECL},  {GETOPT_VERSION_OPTION_DECL},  {0, 0, 0, 0},};/* The set of signals that are caught.  */static sigset_t caught_signals;/* The list of temporary files. */struct tempnode{  struct tempnode *volatile next;  char name[1];  /* Actual size is 1 + file name length.  */};static struct tempnode *volatile temphead;/* Clean up any remaining temporary files. */static voidcleanup (void){  struct tempnode *node;  for (node = temphead; node; node = node->next)    unlink (node->name);}/* Report MESSAGE for FILE, then clean up and exit.  */static void die (char const *, char const *) ATTRIBUTE_NORETURN;static voiddie (char const *message, char const *file){  error (0, errno, "%s: %s", message, file);  exit (SORT_FAILURE);}/* Create a new temporary file, returning its newly allocated name.   Store into *PFP a stream open for writing.  */static char *create_temp_file (FILE **pfp){  static char const slashbase[] = "/sortXXXXXX";  static size_t temp_dir_index;  sigset_t oldset;  int fd;  int saved_errno;  char const *temp_dir = temp_dirs[temp_dir_index];  size_t len = strlen (temp_dir);  struct tempnode *node =    (struct tempnode *) xmalloc (sizeof node->next + len + sizeof slashbase);  char *file = node->name;  memcpy (file, temp_dir, len);  memcpy (file + len, slashbase, sizeof slashbase);  node->next = temphead;  if (++temp_dir_index == temp_dir_count)    temp_dir_index = 0;  /* Create the temporary file in a critical section, to avoid races.  */  sigprocmask (SIG_BLOCK, &caught_signals, &oldset);  fd = mkstemp (file);  if (0 <= fd)    temphead = node;  saved_errno = errno;  sigprocmask (SIG_SETMASK, &oldset, NULL);  errno = saved_errno;  if (fd < 0 || (*pfp = fdopen (fd, "w")) == NULL)    die (_("cannot create temporary file"), file);  return file;}static FILE *xfopen (const char *file, const char *how){  FILE *fp;  if (STREQ (file, "-"))    {      if (*how == 'r')	{	  have_read_stdin = 1;	  fp = stdin;	}      else	fp = stdout;    }  else    {      if ((fp = fopen_safer (file, how)) == NULL)	die (_("open failed"), file);    }  return fp;}/* Close FP, whose name is FILE, and report any errors.  */static voidxfclose (FILE *fp, char const *file){  if (fp == stdin)    {      /* Allow reading stdin from tty more than once. */      if (feof (fp))	clearerr (fp);    }  else    {      if (fclose (fp) != 0)	die (_("close failed"), file);    }}static voidwrite_bytes (const char *buf, size_t n_bytes, FILE *fp, const char *output_file){  if (fwrite (buf, 1, n_bytes, fp) != n_bytes)    die (_("write failed"), output_file);}/* Append DIR to the array of temporary directory names.  */static voidadd_temp_dir (char const *dir)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久精品国产毛片| 99免费精品在线| 国产精品视频在线看| 麻豆freexxxx性91精品| 中文字幕av不卡| 日韩一区二区三区观看| 成人久久18免费网站麻豆 | 欧美成人精品3d动漫h| 韩国成人精品a∨在线观看| 亚洲欧美偷拍三级| 欧美一区二区三区啪啪| av在线播放成人| 蜜桃av一区二区三区电影| 日韩伦理电影网| 亚洲欧美日韩中文播放| 欧美色大人视频| 国产成人综合自拍| 亚洲不卡一区二区三区| 国产亚洲一区二区三区在线观看| 色94色欧美sute亚洲线路二| 韩国毛片一区二区三区| 亚洲网友自拍偷拍| 中文字幕亚洲一区二区va在线| 91精品国产欧美日韩| 99视频一区二区三区| 激情文学综合网| 国产欧美一区二区三区网站| 在线免费亚洲电影| 成人一区二区视频| 精品在线你懂的| 午夜久久久久久久久久一区二区| 国产精品高清亚洲| 久久看人人爽人人| 欧美成人欧美edvon| 欧美日免费三级在线| 波波电影院一区二区三区| 激情综合亚洲精品| 日韩精彩视频在线观看| 一区二区三区电影在线播| 日本一区二区三区四区在线视频| 欧美一区二区三区白人| 欧美日韩在线亚洲一区蜜芽| 99re在线精品| 99在线热播精品免费| 国产精品一品二品| 经典三级视频一区| 美女高潮久久久| 天使萌一区二区三区免费观看| 亚洲va韩国va欧美va精品| 亚洲精品成a人| 亚洲天堂成人在线观看| 中文字幕亚洲区| 国产精品蜜臀在线观看| 国产精品视频免费| 中文字幕免费不卡在线| 国产精品网曝门| 国产精品色哟哟| 国产精品免费网站在线观看| 国产女同性恋一区二区| 国产女人18毛片水真多成人如厕| 久久精品人人做人人爽人人| 久久亚洲综合av| 国产欧美一区二区精品仙草咪| 久久久久国产精品厨房| 国产视频在线观看一区二区三区| 久久久久久综合| 午夜电影久久久| 日本欧美大码aⅴ在线播放| 日韩av高清在线观看| 久久精品国产77777蜜臀| 久久精品国产99久久6| 国产综合色产在线精品| 高清不卡一区二区| 欧洲亚洲精品在线| 欧美一区二区三区日韩| 日本一区二区三区在线不卡| 亚洲少妇屁股交4| 亚洲最新视频在线观看| 日韩二区三区四区| 国产精品一区一区| av电影在线观看完整版一区二区| 色94色欧美sute亚洲13| 宅男在线国产精品| 久久午夜电影网| 亚洲三级在线观看| 视频一区视频二区中文| 激情图片小说一区| 99这里只有久久精品视频| 欧美性做爰猛烈叫床潮| 日韩视频国产视频| 国产精品视频观看| 亚洲精品免费在线观看| 蜜桃精品视频在线| 99久久精品国产麻豆演员表| 欧美军同video69gay| 久久无码av三级| 一区二区三区在线不卡| 蜜桃精品视频在线| caoporm超碰国产精品| 欧美精品久久99久久在免费线 | 国产精品亚洲视频| 国产中文一区二区三区| 国模娜娜一区二区三区| 色婷婷精品大在线视频| 日韩欧美的一区| 国产精品传媒在线| 午夜精品久久久久久| 精品一区二区三区免费播放| 久久超碰97人人做人人爱| 成人激情午夜影院| 欧美高清www午色夜在线视频| 久久久国产精品不卡| 一区二区三区中文字幕| 日本不卡中文字幕| 国产成人一区二区精品非洲| 欧美丝袜丝nylons| 欧美精品一区二区在线播放| 亚洲另类在线制服丝袜| 加勒比av一区二区| 欧美三区在线观看| 国产精品视频一区二区三区不卡| 亚洲www啪成人一区二区麻豆| 风间由美中文字幕在线看视频国产欧美| 欧美吻胸吃奶大尺度电影| 国产欧美va欧美不卡在线| 日韩精品亚洲专区| 97精品视频在线观看自产线路二| 欧美日韩亚洲国产综合| 国产精品网站在线| 蜜臀久久99精品久久久画质超高清| voyeur盗摄精品| 久久综合九色综合久久久精品综合| 亚洲一区二区三区四区五区黄| 国产jizzjizz一区二区| 日韩一区二区三区在线视频| 亚洲一区二区三区四区五区中文| 成人精品视频一区二区三区| 精品国产污污免费网站入口| 午夜婷婷国产麻豆精品| 色诱视频网站一区| 一色屋精品亚洲香蕉网站| 国产成人久久精品77777最新版本| 欧美一级淫片007| 天天影视色香欲综合网老头| 欧美在线视频日韩| 亚洲综合自拍偷拍| 欧美日韩久久久一区| 夜夜操天天操亚洲| 色婷婷国产精品| 亚洲免费在线看| 色婷婷精品大视频在线蜜桃视频| **欧美大码日韩| 91在线porny国产在线看| 日韩美女视频19| 一本久久综合亚洲鲁鲁五月天 | 精品成人一区二区三区| 久久精品国产**网站演员| 精品国产一区二区亚洲人成毛片 | 人妖欧美一区二区| 欧美美女一区二区| 亚洲韩国一区二区三区| 欧美人牲a欧美精品| 五月婷婷综合网| 欧美一区二区美女| 久久99精品一区二区三区三区| 精品第一国产综合精品aⅴ| 国产精品一区免费视频| 中文字幕精品一区| 色婷婷综合五月| 亚洲妇女屁股眼交7| 欧美一区二区网站| 国产在线播放一区二区三区| 国产欧美中文在线| 一本到不卡免费一区二区| 亚洲国产另类av| 精品国产伦一区二区三区免费| 国产精品乡下勾搭老头1| 一色桃子久久精品亚洲| 欧美中文字幕亚洲一区二区va在线 | 99热精品一区二区| 一区二区三区在线视频播放| 欧美日韩成人激情| 精品亚洲aⅴ乱码一区二区三区| 久久久久久久久伊人| 成人一级片在线观看| 亚洲无人区一区| 久久综合久久99| 成a人片国产精品| 日韩中文字幕不卡| 日韩欧美国产综合| 成人免费不卡视频| 亚洲动漫第一页| 国产午夜精品福利| 欧美日韩国产天堂| 国产激情一区二区三区| 亚洲制服丝袜一区| 久久欧美中文字幕| 在线亚洲一区二区| 成人精品视频一区二区三区| 首页国产欧美久久|