]> git.lyx.org Git - lyx.git/blobdiff - src/ImportNoweb.C
Baruch's graphic-inset patch.
[lyx.git] / src / ImportNoweb.C
index 4748e5aaf4112f7e97fe12245977b30d305fdb04..31c30bdd7890cb299200e6a7aeea0f71f604c13e 100644 (file)
@@ -3,7 +3,7 @@
  * 
  *           LyX, The Document Processor        
  *          Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
  *           This file is Copyright 1999
  *           Kayvan A. Sylvan
 #endif
 
 #include <fstream>
+#include <cstdlib>
 
 #include "ImportNoweb.h"
 #include "lyxrc.h"
 #include "support/syscall.h"
 #include "bufferlist.h"
 
-extern LyXRC * lyxrc;
+using std::ifstream;
+using std::getline;
+
 extern BufferList bufferlist;
 
 /*
@@ -34,7 +37,7 @@ extern BufferList bufferlist;
 Buffer * ImportNoweb::run()
 {
        // run reLyX -n
-       string tmp = lyxrc->relyx_command + " -n -c " +
+       string tmp = lyxrc.relyx_command + " -n -c " +
                                        documentclass() + " -f " + file;
         Systemcalls one;
        Buffer * buf = 0;
@@ -53,20 +56,16 @@ string ImportNoweb::documentclass()
 {
        string result = "literate-article"; // Default
 
-#warning If you use literate programming you should verify that this works
-       // This method has been rewritten to use ifstream, but since I
-       // don't use literate programming myself I am unable to check
-       // this correclty. (Lgb)
        ifstream ifs(file.c_str());
 
        if (!ifs) return "nofile"; // Should not happen!
        string line;
        while (getline(ifs, line)) {
-               int p = line.find("\\documentclass");
+               string::size_type p = line.find("\\documentclass");
                if (p != string::npos) {
                        p = line.find('{', p);
-                       int q = line.find('}', p);
-                       result = "literate-" + line.substr(p, q - p);
+                       string::size_type q = line.find('}', p);
+                       result = "literate-" + line.substr(p + 1, q - p - 1);
                        break;
                }
        }