Commit Diff


commit - dae44186d68958fc415607eb19d24d7befb178d7
commit + 470927252fcd4952bfd15f13f01cf614f98012c9
blob - b049715f67ae624bd8c152fcaa2f30b82d0364c1
blob + e145a182c8e3e56b544d5b9b8d005296aab94fb3
--- pdf.c
+++ pdf.c
@@ -2179,57 +2179,19 @@ basename(const char *fn)
  * and writes it out to a file.
  */
 void
-text_extract(struct Env *aux, const char *outfn, const char *outfn2)
+text_extract(struct Env *aux, const char *outfn)
 {
-	FILE *stream, *stream2;
+	FILE *stream;
 	struct textnode *cur;
 
-	// open the files for writing
-	if (outfn && !(stream = fopen(outfn, "w")))
+	/* open the file for writing */
+	if ((stream = fopen(outfn, "w")) == NULL)
 		err(2, "%s", outfn);
-	if (outfn2 && !(stream2 = fopen(outfn2, "w")))
-		err(2, "%s", outfn2);
 
-	for (cur = aux->txthead; cur != NULL; cur = cur->next) {
-		if (outfn)
-			fwrite(cur->tstr->text, 1, cur->tstr->nchars, stream);
-
-		if (outfn2) {
-			const HParsedToken *tt_text = cur->tstr->tobj;
+	for (cur = aux->txthead; cur != NULL; cur = cur->next)
+		fwrite(cur->tstr->text, 1, cur->tstr->nchars, stream);
 
-			for (int j = 0; j < tt_text->seq->used; j++) {
-				struct textstr *tstr = NULL;
-				TextEntry *txte = H_CAST(TextEntry,
-				    tt_text->seq->elements[j]);
-
-				switch (txte->type) {
-				case TW_Tj:
-				case TW_Tq:
-				case TW_Tqq:
-					tstr = &txte->tstr;
-					break;
-				case TW_TJ:
-					tstr = &txte->tarray.flattened;
-					break;
-				default:
-					continue;
-				}
-				assert(tstr != NULL);
-
-				Fontinfo_T *ft = lookup_font(&txte->node->ts, aux);
-				if (ft)
-					pp_fontinfo(stream2, &txte->node->ts, ft);
-				else
-					fputs("\nMissing Font Info!!\n", stream2);
-				fwrite(tstr->text, 1, tstr->nchars, stream2);
-			}
-		}
-	}
-
-	if (outfn)
-		fclose(stream);
-	if (outfn2)
-		fclose(stream2);
+	fclose(stream);
 }
 
 
@@ -4892,7 +4854,7 @@ extern int optind;
 /* command line arguments */
 const char *progname;
 const char *infile;
-const char *xfile, *Xfile;
+const char *xfile;
 int qflag, vflag, dflag;
 int onum = -1, ogen = -1;	/* -1 means unspecified */
 
@@ -5065,7 +5027,7 @@ main(int argc, char *argv[])
 
 	/* command line handling */
 	progname = argv[0];
-	while ((ch = getopt(argc, argv, "d:L:qsS:vx:X:")) != -1) {
+	while ((ch = getopt(argc, argv, "d:L:qsS:vx:")) != -1) {
 		switch(ch) {
 		case 'd':	/* dump object */
 			if (strlen(optarg) != 1 || 
@@ -5097,9 +5059,6 @@ main(int argc, char *argv[])
 		case 'x':
 			xfile = optarg;
 			break;
-		case 'X':
-			Xfile = optarg;
-			break;
 		default:
 			usage();
 		}
@@ -5197,9 +5156,9 @@ main(int argc, char *argv[])
 	}
 
 	/* extract text if requested */
-	if (xfile != NULL || Xfile != NULL) {
+	if (xfile != NULL) {
 		process_page_content(&aux);
-		text_extract(&aux, xfile, Xfile);
+		text_extract(&aux, xfile);
 	}
 
 #ifdef LEAKCHECK