<commit_before>/* handles all html operations */

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

#include <glib.h>

#include "data.h"
#include "html.h"
#include "parse.h"
#include "utils.h"

#define USE_FILE_URLS

int inTable=0;

char *BaseFilename=NULL;
char *OverrideBaseFilename=NULL;

/* prototypes */
char *form_info_tag_href( char *nodefile, char *nodename );
int make_Top_link( char *destdir, char *destfile );
int make_info_dir( char *destdir );
void write_node_link_html( FILE *f, char *nodefile, char *refname, char *ref );
void start_html_content( FILE *f );
void make_nav_links( FILE *f, NODE *node );
void html_error( char *s, char *p, char *q );


/* print out the url for a info file */
char *form_info_tag_href( char *nodefile, char *nodename )
{
  char tmp[1024];
  char *escaped_nodename;
  char *filename;

  escaped_nodename = escape_html_chars( nodename );
  if (!strcmp(BaseFilename, nodefile))
    {
	  if (OverrideBaseFilename)
		  filename = OverrideBaseFilename;
	  else 
		  filename = BaseFilename;
    }
  else
	  filename = nodefile;

  g_snprintf(tmp,sizeof(tmp),"HREF=\"info:%s#%s\"", filename, escaped_nodename );
  if (escaped_nodename)
    g_free(escaped_nodename);
  return g_strdup(tmp);
}


/* returns zero if success making link from destfile -> index.html in */
/* specified directory. If it already exists, just returns with success */
int make_Top_link( char *destdir, char *destfile )
{
  struct stat filestat;
  char *indexlink;
  
  indexlink = (char *) g_malloc( strlen(destdir) + 20);
  strcpy(indexlink, destdir);
  strcat(indexlink, "/index.html");
  
  if (lstat(indexlink, &filestat))
    {<commit_msg>Changed so that info anchor tag uri's are always local. Fixes bug 6756.<commit_after>/* handles all html operations */

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

#include <glib.h>

#include "data.h"
#include "html.h"
#include "parse.h"
#include "utils.h"

#define USE_FILE_URLS

int inTable=0;

char *BaseFilename=NULL;
char *OverrideBaseFilename=NULL;

/* prototypes */
char *form_info_tag_href( char *nodefile, char *nodename );
int make_Top_link( char *destdir, char *destfile );
int make_info_dir( char *destdir );
void write_node_link_html( FILE *f, char *nodefile, char *refname, char *ref );
void start_html_content( FILE *f );
void make_nav_links( FILE *f, NODE *node );
void html_error( char *s, char *p, char *q );


/* print out the url for a info file */
char *form_info_tag_href( char *nodefile, char *nodename )
{
  char tmp[1024];
  char *escaped_nodename;
  char *filename;

  escaped_nodename = escape_html_chars( nodename );
  if (!strcmp(BaseFilename, nodefile))
    {
	  if (OverrideBaseFilename)
		  filename = OverrideBaseFilename;
	  else 
		  filename = BaseFilename;
    }
  else
	  filename = nodefile;

  g_snprintf (tmp, sizeof (tmp), "HREF=\"#%s\"", escaped_nodename);

  if (escaped_nodename)
    g_free(escaped_nodename);
  return g_strdup(tmp);
}


/* returns zero if success making link from destfile -> index.html in */
/* specified directory. If it already exists, just returns with success */
int make_Top_link( char *destdir, char *destfile )
{
  struct stat filestat;
  char *indexlink;
  
  indexlink = (char *) g_malloc( strlen(destdir) + 20);
  strcpy(indexlink, destdir);
  strcat(indexlink, "/index.html");
  
  if (lstat(indexlink, &filestat))
    {
{'fraction_non_alphanumeric': 0.1338432122370937, 'fraction_numerical': 0.004916689429117728, 'mean_word_length': 4.482035928143713, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715049', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1315, 'n_words': 365}