*** Original/src/c/files	Thu Nov 29 21:11:28 2001
--- RISCOS/c/files	Thu Nov 29 22:02:26 2001
***************
*** 63,68 ****
--- 63,70 ----
  /**
   * redirectToTerminal:
   * @device: terminal to redirect i/o to , will not work under win32
+  * Returns 1 if successful,
+  *         0 if failed
   */
  int
  openTerminal(xmlChar *device)
***************
*** 71,77 ****
    FILE oldStdout = *stdout;
  
    if (!device)
!     return;
  
  #ifdef HAVE_UNISTD /* fix me for WinNT, risc os!! */
    if (terminalIO != NULL)
--- 73,112 ----
    FILE oldStdout = *stdout;
  
    if (!device)
!     return 0; /* Failed; there's no device */
! 
! #ifdef __riscos
!   /*
!      On RISC OS, you get one terminal - the screen.
!      we assume that the parameter is meant to be an output device as
!      per normal - we can use vdu:, rawvdu: or :tt, or a filename for
!      normal VDU output, VDU output without newline expansion,
!      C terminal output with control code escaping, or a raw file
!      respectively.
!      The name passed is expected to be in native file format - no
!      URI escaping here.
!      One assumes that you might use a socket or a pipe here.
!    */
!   if (terminalIO != NULL)
!     fclose(terminalIO);
! 
!   if (device[0]=='\0') {
!     /* look like we are supposed to close the terminal */
!     selectNormalIO();/* shouldn't be needed but just in case */
!   } else {
!     terminalIO = fopen((char *)device,"r+");
!     if (terminalIO != NULL) {
!       termName = (char *)device; /* JRF: Not sure how safe this is */
!       /* This can't be done reliably; really need more thought */
!       result++;
!     } else {
!       xsltGenericError(xsltGenericErrorContext,
! 		     "Unable to open terminal %s", device);
!       termName = NULL;
!     }
!   }
! 
! #endif
  
  #ifdef HAVE_UNISTD /* fix me for WinNT, risc os!! */
    if (terminalIO != NULL)
***************
*** 161,167 ****
         but we may have made a relative match */
      if (xmlStrCmp(style->doc->URL, searchData->nameInput) == 0){
        /* absolute path match great!*/
!       searchData->absoluteNameMatch = (xmlChar*)xmlMemStrdup(style->doc->URL);
        return;
      }
  
--- 196,202 ----
         but we may have made a relative match */
      if (xmlStrCmp(style->doc->URL, searchData->nameInput) == 0){
        /* absolute path match great!*/
!       searchData->absoluteNameMatch = (xmlChar*)xmlMemStrdup((char *)style->doc->URL);
        return;
      }
  
***************
*** 175,181 ****
      }
      if (xmlStrCmp(style->doc->URL, buffer) == 0){
        /* guessed right!*/
!       searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup(buffer);
        return;
      }
  
--- 210,216 ----
      }
      if (xmlStrCmp(style->doc->URL, buffer) == 0){
        /* guessed right!*/
!       searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup((char *)buffer);
        return;
      }
  
***************
*** 186,192 ****
      }
      if ( xmlStrCmp(style->doc->URL, buffer) == 0){
        /* guessed right!*/
!       searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup(buffer);
        return;
      }
  
--- 221,227 ----
      }
      if ( xmlStrCmp(style->doc->URL, buffer) == 0){
        /* guessed right!*/
!       searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup((char *)buffer);
        return;
      }
  
***************
*** 198,204 ****
  	    lastSlash++; /* skip the slash */
  	    if (xmlStrCmp(lastSlash, searchData->nameInput) == 0){
  	      /* guessed right!*/
! 	      searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup(style->doc->URL);
  	    }
  	  }
      }
--- 233,239 ----
  	    lastSlash++; /* skip the slash */
  	    if (xmlStrCmp(lastSlash, searchData->nameInput) == 0){
  	      /* guessed right!*/
! 	      searchData->guessedNameMatch = (xmlChar*)xmlMemStrdup((char *)style->doc->URL);
  	    }
  	  }
      }
***************
*** 215,221 ****
  xmlChar *guessStyleSheetName(xmlChar* name)
  {
    xmlChar *result = NULL;
!   FileSearch searchData = {name, NULL, NULL};
    if (name){
      walkStylesheets((xmlHashScanner)guessStyleSheetHelper, &searchData,
  		     getStylesheet());
--- 250,264 ----
  xmlChar *guessStyleSheetName(xmlChar* name)
  {
    xmlChar *result = NULL;
!   FileSearch searchData;
! 
!   /* JRF: Need to initialise local structure; cannot initialise with
!      variable in automatic initialisation.
!      'illegal use of variable in pointer initialiser' */
!   searchData.nameInput = name;
!   searchData.absoluteNameMatch = NULL;
!   searchData.guessedNameMatch = NULL;
! 
    if (name){
      walkStylesheets((xmlHashScanner)guessStyleSheetHelper, &searchData,
  		     getStylesheet());
***************
*** 235,241 ****
   *        ie URL minus the actual file name
   */
  xmlChar *
! stylePath()
  {
    return stylePathName;
  }
--- 278,284 ----
   *        ie URL minus the actual file name
   */
  xmlChar *
! stylePath(void)
  {
    return stylePathName;
  }
***************
*** 246,252 ****
   * Return the working directory as set by changeDir function
   */
  xmlChar*
! workingPath()
  {
    return workingDirPath;
  }
--- 289,295 ----
   * Return the working directory as set by changeDir function
   */
  xmlChar*
! workingPath(void)
  {
    return workingDirPath;
  }
***************
*** 268,274 ****
         /* must have path char at end of path name*/
        xmlStrCpy(buffer, path);
        xmlStrCat(buffer, endString);
!       workingDirPath = (xmlChar*)xmlMemStrdup(buffer);
        result++;
      }
      if (!result)
--- 311,317 ----
         /* must have path char at end of path name*/
        xmlStrCpy(buffer, path);
        xmlStrCat(buffer, endString);
!       workingDirPath = (xmlChar*)xmlMemStrdup((char *)buffer);
        result++;
      }
      if (!result)
***************
*** 322,331 ****
              if (top_style && top_style->doc){
  	      /* look for last slash (or baskslash) of URL*/
  	       char *lastSlash =   xmlStrrChr(top_style->doc->URL, PATHCHAR);
! 	       const char *docUrl = top_style->doc->URL;
                  result++;
  		if (docUrl && lastSlash){
! 		    stylePathName = xmlMemStrdup(docUrl);
  		    stylePathName[lastSlash - docUrl + 1] = '\0';
  		    if (isOptionEnabled(OPTIONS_SHELL)) {
  		    	xsltGenericError(xsltGenericErrorContext,
--- 365,374 ----
              if (top_style && top_style->doc){
  	      /* look for last slash (or baskslash) of URL*/
  	       char *lastSlash =   xmlStrrChr(top_style->doc->URL, PATHCHAR);
! 	       const char *docUrl = (const char *)top_style->doc->URL;
                  result++;
  		if (docUrl && lastSlash){
! 		    stylePathName = (xmlChar *)xmlMemStrdup(docUrl);
  		    stylePathName[lastSlash - docUrl + 1] = '\0';
  		    if (isOptionEnabled(OPTIONS_SHELL)) {
  		    	xsltGenericError(xsltGenericErrorContext,
***************
*** 464,469 ****
--- 507,515 ----
  {
      int result = 0;
      terminalIO = NULL;
+ #ifdef __riscos
+     ttyName = ":tt"; /* Default tty */
+ #endif
  #ifdef HAVE_UNISTD
      ttyName = ttyname(fileno(stdin));
      /* save out io for when/if we send debugging to a terminal */
