rc.documentStart(box.horizontalExtent(), box.verticalExtent());
{ rc.documentStart(box.horizontalExtent(), box.verticalExtent()); view->render(rc, 0, box.height); }
main(int argc, char* argv[]){  while (true)    {      int option_index = 0;      static struct option long_options[] =	{	  { "version", 	       no_argument,       NULL, OPTION_VERSION },	  { "help",    	       no_argument,       NULL, OPTION_HELP },	  { "verbose",         optional_argument, NULL, OPTION_VERBOSE },	  { "size",            required_argument, NULL, OPTION_SIZE },	  { "unit",            required_argument, NULL, OPTION_UNIT },	  { "margins",         required_argument, NULL, OPTION_MARGINS },	  { "font-size",       required_argument, NULL, OPTION_FONT_SIZE },	  { "crop",            optional_argument, NULL, OPTION_CROP },	  { "cut-filename",    optional_argument, NULL, OPTION_CUT_FILENAME },	  { "config",          required_argument, NULL, OPTION_CONFIG },	  { NULL,              no_argument, NULL, 0 }	};      int c = getopt_long(argc, argv, "vhg:u:m:f:r::", long_options, &option_index);      if (c == -1) break;      switch (c) {      case OPTION_VERSION:      case 'v':	printVersion();	break;      case OPTION_HELP:      case 'h':	printHelp();	break;      case OPTION_SIZE:      case 'g':	if (optarg == NULL) printHelp();	if (!parseSize(optarg)) parseError("size");	break;      case OPTION_UNIT:      case 'u':	if (optarg == NULL) printHelp();	if (!parseUnit(optarg)) parseError("unit");	break;      case OPTION_MARGINS:      case 'm':	if (optarg == NULL) printHelp();	if (!parseMargins(optarg)) parseError("margins");	break;      case OPTION_VERBOSE:	if (optarg && (*optarg < '0' || *optarg > '3')) printHelp();	else if (optarg == NULL) logLevel = LOG_ERROR;	else logLevel = *optarg - '0';	logLevelSet = true;	break;      case OPTION_FONT_SIZE:      case 'f':	if (optarg == NULL) printHelp();	fontSize = atof(optarg);	break;      case OPTION_CROP:      case 'r':	if (optarg == NULL) cropping = true;	else if (!parseBoolean(optarg, cropping)) parseError("crop");	break;      case OPTION_CUT_FILENAME:	if (optarg == NULL) cutFileName = true;	else if (!parseBoolean(optarg, cutFileName)) parseError("cut-filename");	break;      case OPTION_CONFIG:	configPath = optarg;	break;      case '?':	break;      default:	fprintf(stderr, "*** getopt returned %o value\n", c);	break;      }    }  if (configPath == NULL) configPath = getenv("MATHENGINECONF");  if (optind >= argc)    {      printHelp();      exit(1);    }  SmartPtr<AbstractLogger> logger = Logger::create();  logger->setLogLevel(LogLevelId(logLevel));  SmartPtr<Configuration> configuration = initConfiguration<MathView>(logger, configPath);  SmartPtr<SVG_MathGraphicDevice> mgd = SVG_MathGraphicDevice::create(logger, configuration);  if (logLevelSet) logger->setLogLevel(LogLevelId(logLevel));  SmartPtr<MathMLOperatorDictionary> dictionary = initOperatorDictionary<MathView>(logger, configuration);  logger->out(LOG_INFO, "Font size : %f", fontSize);  logger->out(LOG_INFO, "Paper size: %fx%f", width, height);  logger->out(LOG_INFO, "Margins   : %fx%f", xMargin, yMargin);  SmartPtr<MathView> view = MathView::create();  view->setLogger(logger);  view->setOperatorDictionary(dictionary);  view->setMathMLNamespaceContext(MathMLNamespaceContext::create(view, mgd));  view->setDefaultFontSize(static_cast<unsigned>(fontSize));#if ENABLE_BOXML  FormattingContext context(mgd, 0);#else  FormattingContext context(mgd);#endif  const scaled widthS = mgd->evaluate(context, Length(width, unitId), scaled::zero());  const scaled heightS = mgd->evaluate(context, Length(height, unitId), scaled::zero());  const scaled xMarginS = mgd->evaluate(context, Length(xMargin, unitId), scaled::zero());  const scaled yMarginS = mgd->evaluate(context, Length(yMargin, unitId), scaled::zero());  view->setAvailableWidth(widthS - xMarginS * 2);  while (optind < argc)    {      logger->out(LOG_INFO, "Processing `%s'...", argv[optind]);      char* outName = getOutputFileName(argv[optind]);      assert(outName != NULL);      xmlTextReaderPtr reader = xmlNewTextReaderFilename(argv[optind]);      assert(reader);      view->loadReader(reader);      const BoundingBox box = view->getBoundingBox();      std::ofstream os(outName);      SVG_StreamRenderingContext rc(logger, os);      if (cropping)	rc.documentStart(box.horizontalExtent(), box.verticalExtent());      else	rc.documentStart(widthS, heightS);      view->render(rc, xMarginS, yMarginS + box.height);      rc.documentEnd();      view->resetRootElement();      os.close();      // WARNING: currently the text reader is freed by libxmlXmlReader      // not sure this is what we want      //xmlFreeTextReader(reader);      optind++;    }  return 0;}