Commit 8db7cdf4 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added -s flag to gather statistics about text lengths.

parent 6cb4d59a
/* /*
* $Id: dbck.c,v 0.7 1992/01/05 18:48:41 ceder Exp $ * $Id: dbck.c,v 0.8 1992/02/21 00:51:37 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association. * Copyright (C) 1991 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* Author: Per Cederqvist. * Author: Per Cederqvist.
*/ */
static char *rcsid = "$Id: dbck.c,v 0.7 1992/01/05 18:48:41 ceder Exp $"; static char *rcsid = "$Id: dbck.c,v 0.8 1992/02/21 00:51:37 ceder Exp $";
#include <stdarg.h> #include <stdarg.h>
...@@ -57,6 +57,7 @@ int vflag=0; /* Verbose - list statistics also. */ ...@@ -57,6 +57,7 @@ int vflag=0; /* Verbose - list statistics also. */
int iflag=0; /* Interactive - prompt user and repair. */ int iflag=0; /* Interactive - prompt user and repair. */
int rflag=0; /* Repair simple error without confirmation. */ int rflag=0; /* Repair simple error without confirmation. */
int gflag=0; /* Garbage collect text-file. */ int gflag=0; /* Garbage collect text-file. */
int sflag=0; /* Statistic flag. */
int modifications = 0; int modifications = 0;
...@@ -1085,25 +1086,6 @@ post_check_persons(void) ...@@ -1085,25 +1086,6 @@ post_check_persons(void)
log("INTERNAL DBCK ERROR: post_check_persons(): can't " log("INTERNAL DBCK ERROR: post_check_persons(): can't "
"cached_get_person_stat(%d).\n", pers_no); "cached_get_person_stat(%d).\n", pers_no);
} }
if ( person_scratchpad[pers_no]->created_confs
!= pstat->created_confs )
{
log("Person %d has created %d conferences, not %d (as said in "
"his person-stat).\n",
pers_no, person_scratchpad[pers_no]->created_confs,
pstat->created_confs);
if ( rflag || confirm("Repair by altering person-stat? ") )
{
pstat->created_confs
= person_scratchpad[pers_no]->created_confs;
mark_person_as_changed(pers_no);
modifications++;
log("Person-stat corrected.\n");
}
else
errors++;
}
} }
return errors; return errors;
...@@ -1174,6 +1156,33 @@ garb_text_file(void) ...@@ -1174,6 +1156,33 @@ garb_text_file(void)
void
print_statistics(void)
{
Text_stat *ts;
Text_no t;
int *hist;
int i;
hist = calloc(TEXT_LEN, sizeof(int));
for (t=0; (t=traverse_text(t)) != 0;)
{
ts = cached_get_text_stat(t);
if (ts == NULL)
{
log("print_statistics(): Can't get text_stat.\n");
return;
}
hist[ts->no_of_chars]++;
}
log("Length Frequency\n");
for(i=0; i<TEXT_LEN; i++)
if(hist[i] != 0)
log("%8d %d\n", i, hist[i]);
}
int int
...@@ -1214,6 +1223,10 @@ main (int argc, ...@@ -1214,6 +1223,10 @@ main (int argc,
gflag++; gflag++;
break; break;
case 's': /* Statistics: text length et c. */
sflag++;
break;
default: default:
restart_kom("usage: %s [-d] [-Ddir] [-i] [-r] [-v] [-g]\n", restart_kom("usage: %s [-d] [-Ddir] [-i] [-r] [-v] [-g]\n",
argv[0]); argv[0]);
...@@ -1239,6 +1252,9 @@ main (int argc, ...@@ -1239,6 +1252,9 @@ main (int argc,
log("ready.\n"); log("ready.\n");
} }
if ( sflag )
print_statistics();
if ( gflag ) if ( gflag )
{ {
if ( modifications == 0 && errors == 0 ) if ( modifications == 0 && errors == 0 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment