[前][次][番号順一覧][スレッド一覧]

ruby-changes:55498

From: Hiroshi <ko1@a...>
Date: Tue, 23 Apr 2019 22:26:51 +0900 (JST)
Subject: [ruby-changes:55498] Hiroshi SHIBATA:14dd8d6b37 (trunk): Added cgit url.

Hiroshi SHIBATA	2019-04-23 22:26:40 +0900 (Tue, 23 Apr 2019)

  New Revision: 14dd8d6b37

  https://git.ruby-lang.org/ruby.git/commit/?id=3D14dd8d6b37

  Log:
    Added cgit url.

  Modified files:
    NEWS=
Index: v1_1r/sample/list2.rb
===================================================================
--- v1_1r/sample/list2.rb	(nonexistent)
+++ v1_1r/sample/list2.rb	(revision 14)
@@ -0,0 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/sample/list2.rb#L1
+# Linked list example -- short version
+class Point
+  def initialize(x, y)
+    @x = x; @y = y
+    self
+  end
+
+  def to_s
+    sprintf("%d@%d", @x, @y)
+  end
+end
+    
+list1 = [10, 20, Point.new(2, 3), Point.new(4, 5)]
+list2 = [20, Point.new(4, 5), list1]
+print("list1:\n", list1.join("\n"), "\n")
+print("list2:\n", list2.join("\n"), "\n")

Property changes on: v1_1r/sample/list2.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: v1_1r/sample/rubydb3x.el
===================================================================
--- v1_1r/sample/rubydb3x.el	(nonexistent)
+++ v1_1r/sample/rubydb3x.el	(revision 14)
@@ -0,0 +1,104 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/sample/rubydb3x.el#L1
+(require 'gud)
+(provide 'rubydb)
+
+;; ======================================================================
+;; rubydb functions
+
+;;; History of argument lists passed to rubydb.
+(defvar gud-rubydb-history nil)
+
+(defun gud-rubydb-massage-args (file args)
+  (cons "-r" (cons "debug" args)))
+
+;; There's no guarantee that Emacs will hand the filter the entire
+;; marker at once; it could be broken up across several strings.  We
+;; might even receive a big chunk with several markers in it.  If we
+;; receive a chunk of text which looks like it might contain the
+;; beginning of a marker, we save it here between calls to the
+;; filter.
+(defvar gud-rubydb-marker-acc "")
+
+(defun gud-rubydb-marker-filter (string)
+  (setq gud-marker-acc (concat gud-marker-acc string))
+  (let ((output ""))
+
+    ;; Process all the complete markers in this chunk.
+    (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
+			 gud-marker-acc)
+      (setq
+
+       ;; Extract the frame position from the marker.
+       gud-last-frame
+       (cons (substring gud-marker-acc (match-beginning 1) (match-end 1))
+	     (string-to-int (substring gud-marker-acc
+				       (match-beginning 2)
+				       (match-end 2))))
+
+       ;; Append any text before the marker to the output we're going
+       ;; to return - we don't include the marker in this text.
+       output (concat output
+		      (substring gud-marker-acc 0 (match-beginning 0)))
+
+       ;; Set the accumulator to the remaining text.
+       gud-marker-acc (substring gud-marker-acc (match-end 0))))
+
+    ;; Does the remaining text look like it might end with the
+    ;; beginning of another marker?  If it does, then keep it in
+    ;; gud-marker-acc until we receive the rest of it.  Since we
+    ;; know the full marker regexp above failed, it's pretty simple to
+    ;; test for marker starts.
+    (if (string-match "\032.*\\'" gud-marker-acc)
+	(progn
+	  ;; Everything before the potential marker start can be output.
+	  (setq output (concat output (substring gud-marker-acc
+						 0 (match-beginning 0))))
+
+	  ;; Everything after, we save, to combine with later input.
+	  (setq gud-marker-acc
+		(substring gud-marker-acc (match-beginning 0))))
+
+      (setq output (concat output gud-marker-acc)
+	    gud-marker-acc ""))
+
+    output))
+
+(defun gud-rubydb-find-file (f)
+  (save-excursion
+    (let ((buf (find-file-noselect f)))
+      (set-buffer buf)
+      (gud-make-debug-menu)
+      buf)))
+
+(defvar rubydb-command-name "ruby"
+  "File name for executing ruby.")
+
+;;;###autoload
+(defun rubydb (command-line)
+  "Run rubydb on program FILE in buffer *gud-FILE*.
+The directory containing FILE becomes the initial working directory
+and source-file directory for your debugger."
+  (interactive
+   (list (read-from-minibuffer "Run rubydb (like this): "
+			       (if (consp gud-rubydb-history)
+				   (car gud-rubydb-history)
+				 (concat rubydb-command-name " "))
+			       nil nil
+			       '(gud-rubydb-history . 1))))
+
+  (gud-common-init command-line 'gud-rubydb-massage-args
+		   'gud-rubydb-marker-filter 'gud-rubydb-find-file)
+
+  (gud-def gud-break  "b %l"         "\C-b" "Set breakpoint at current line.")
+;  (gud-def gud-remove "clear %l"     "\C-d" "Remove breakpoint at current line")
+  (gud-def gud-step   "s"            "\C-s" "Step one source line with display.")
+  (gud-def gud-next   "n"            "\C-n" "Step one line (skip functions).")
+  (gud-def gud-cont   "c"            "\C-r" "Continue with display.")
+  (gud-def gud-finish "finish"       "\C-f" "Finish executing current function.")
+  (gud-def gud-up     "up %p"        "<" "Up N stack frames (numeric arg).")
+  (gud-def gud-down   "down %p"      ">" "Down N stack frames (numeric arg).")
+  (gud-def gud-print  "p %e"         "\C-p" "Evaluate ruby expression at point.")
+
+  (setq comint-prompt-regexp "^(rdb:-) ")
+  (setq paragraph-start comint-prompt-regexp)
+  (run-hooks 'rubydb-mode-hook)
+  )

Property changes on: v1_1r/sample/rubydb3x.el
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: v1_1r/sample/getopts.test
===================================================================
--- v1_1r/sample/getopts.test	(nonexistent)
+++ v1_1r/sample/getopts.test	(revision 14)
@@ -0,0 +1,36 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/sample/getopts.test#L1
+#! /usr/local/bin/ruby
+
+load("parsearg.rb")
+
+def usage()
+  printf "Usage:\n"
+  printf "%s -d [-x x] [-y y] [--geometry geom] [--version] [string ...]\n", $0
+end
+
+$USAGE = 'usage'
+parseArgs(0, "d&(x|y)", "dfg", "x:", "y:", "geometry:800x600", "version")
+if ($OPT_d)
+  if $OPT_version
+    printf "version 1.0\n"
+  end
+  if ($OPT_x)
+    printf("x = %d\n", $OPT_x.to_i)
+  end
+  if ($OPT_y)
+    printf("y = %d\n", $OPT_y.to_i)
+  end
+  if ($OPT_geometry)
+    printf("geometry = %s\n", $OPT_geometry)
+  end
+  if $OPT_f
+    printf "f = TRUE\n"
+  end
+  if $OPT_g
+    printf "g = TRUE\n"
+  end
+end
+
+while (ARGV.length != 0)
+  print "other = ", ARGV[0], "\n"
+  ARGV.shift
+end

Property changes on: v1_1r/sample/getopts.test
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: v1_1r/sample/from.rb
===================================================================
--- v1_1r/sample/from.rb	(nonexistent)
+++ v1_1r/sample/from.rb	(revision 14)
@@ -0,0 +1,87 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/sample/from.rb#L1
+#! /usr/local/bin/ruby
+
+require "parsedate"
+require "kconv"
+require "mailread"
+
+include ParseDate
+include Kconv
+
+class String
+
+  public :kconv
+
+  def kconv(code = Kconv::EUC)
+    Kconv.kconv(self, code, Kconv::AUTO)
+  end
+
+  def kjust(len)
+    len += 1
+    me = self[0, len].ljust(len)
+    if me =~ /.$/ and $&.size == 2
+      me[-2, 2] = '  '
+    end
+    me.chop!
+  end
+
+end
+
+if ARGV[0] == '-w'
+  wait = TRUE
+  ARGV.shift
+end
+
+if ARGV.length == 0
+  user = ENV['USER']
+else
+  user = ARGV[0]
+end
+
+[ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
+  break if File.exist? ARGV[0] = "#{m}/mail/#{user}" 
+end
+
+$outcount = 0;
+def fromout(date, from, subj)
+  return if !date
+  y = m = d = 0
+  y, m, d = parsedate(date) if date
+  if from
+    from.gsub! /\n/, ""
+  else
+    from = "sombody@somewhere"
+  end
+  if subj
+    subj.gsub! /\n/, ""
+  else
+    subj = "(nil)"
+  end
+  if ENV['LANG'] =~ /sjis/i
+    lang = Kconv::SJIS
+  else
+    lang = Kconv::EUC
+  end
+  from = from.kconv(lang).kjust(28)
+  subj = subj.kconv(lang).kjust(40)
+  printf "%02d/%02d/%02d [%s] %s\n",y,m,d,from,subj
+  $outcount += 1
+end
+
+for file in ARGV
+  next if !File.exist?(file)
+  f = open(file, "r")
+  while !f.eof?
+    mail = Mail.new(f)
+    fromout mail.header['Date'], mail.header['From'], mail.header['Subject']
+  end
+  f.close
+end
+
+if $outcount == 0
+  print "You have no mail.\n"
+  sleep 2 if wait
+elsif wait
+  system "stty cbreak -echo"
+  getc()
+  system "stty cooked echo"
+end

Property changes on: v1_1r/sample/from.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: v1_1r/time.c
===================================================================
--- v1_1r/time.c	(nonexistent)
+++ v1_1r/time.c	(revision 14)
@@ -0,0 +1,806 @@ https://github.com/ruby/ruby/blob/trunk/v1_1r/time.c#L1
+/************************************************
+
+  time.c -
+
+  $Author$
+  $Date$
+  created at: Tue Dec 28 14:31:59 JST 1993
+
+  Copyright (C) 1993-1996 Yukihiro Matsumoto
+
+************************************************/
+
+#include "ruby.h"
+#include <sys/types.h>
+
+#include <time.h>
+#ifndef NT
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#else
+struct timeval {
+        long    tv_sec;         /* seconds */
+        long    tv_usec;        /* and microseconds */
+};
+#endif
+#endif /* NT */
+
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+#include <math.h>
+
+static VALUE cTime;
+#if defined(HAVE_TIMES) || defined(NT)
+static VALUE S_Tms;
+#endif
+extern VALUE mComparable;
+
+struct time_object {
+    struct timeval tv;
+    struct tm tm;
+#ifndef HAVE_TM_ZONE
+    int gmt;
+#endif
+    int tm_got;
+};
+
+#define GetTimeval(obj, tobj) {\
+    Data_Get_Struct(obj, struct time_object, tobj);\
+}
+
+static VALUE
+time_s_now(class)
+    VALUE class;
+{
+    VALUE obj;
+    struct time_object *tobj;
+
+    obj = Data_Make_Struct(class, struct time_object, 0, 0, tobj);
+    tobj->tm_got=0;
+
+    if (gettimeofday(&(tobj->tv), 0) == -1) {
+	rb_sys_fail("gettimeofday");
+    }
+
+    return obj;
+}
+
+static VALUE
+time_new_internal(class, sec, usec)
+    VALUE class;
+    int sec, usec;
+{
+    VALUE obj;
+    struct time_object *tobj;
+
+    obj = Data_Make_Struct(class, struct time_object, 0, 0, tobj);
+    tobj->tm_got = 0;
+    tobj->tv.tv_sec = sec;
+    tobj->tv.tv_usec = usec;
+
+    return obj;
+}
+
+VALUE
+time_new(sec, usec)
+    int sec, usec;
+{
+    return time_new_internal(cTime, sec, usec);
+}
+
+struct timeval
+time_timeval(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+    struct timeval t;
+
+    switch (TYPE(time)) {
+      case T_FIXNUM:
+	t.tv_sec = FIX2UINT(time);
+	if (t.tv_sec < 0)
+	    ArgError("time must be positive");
+	t.tv_usec = 0;
+	break;
+
+      case T_FLOAT:
+	{
+	    double seconds, microseconds;
+
+	    if (RFLOAT(time)->value < 0.0)
+		ArgError("time must be positive");
+	    seconds = floor(RFLOAT(time)->value);
+	    microseconds = (RFLOAT(time)->value - seconds) * 1000000.0;
+	    t.tv_sec = seconds;
+	    t.tv_usec = microseconds;
+	}
+	break;
+
+      case T_BIGNUM:
+	t.tv_sec = NUM2INT(time);
+	t.tv_usec = 0;
+	break;
+
+      default:
+	if (!obj_is_kind_of(time, cTime)) {
+	    TypeError("Can't convert %s into Time",
+		      rb_class2name(CLASS_OF(time)));
+	}
+	GetTimeval(time, tobj);
+	t = tobj->tv;
+	break;
+    }
+    return t;
+}
+
+static VALUE
+time_s_at(class, time)
+    VALUE class, time;
+{
+    struct timeval tv;
+
+    tv = time_timeval(time);
+    return time_new_internal(class, tv.tv_sec, tv.tv_usec);
+}
+
+static char *months [12] = {
+    "jan", "feb", "mar", "apr", "may", "jun",
+    "jul", "aug", "sep", "oct", "nov", "dec",
+};
+
+static void
+time_arg(argc, argv, args)
+    int argc;
+    VALUE *argv;
+    int *args;
+{
+    VALUE v[6];
+    int i;
+
+    rb_scan_args(argc, argv, "15", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5]);
+
+    args[0] = NUM2INT(v[0]);
+    if (args[0] < 70) args[0] += 100;
+    if (args[0] > 1900) args[0] -= 1900;
+    if (v[1] == Qnil) {
+	args[1] = 0;
+    }
+    else if (TYPE(v[1]) == T_STRING) {
+	args[1] = -1;
+	for (i=0; i<12; i++) {
+	    if (strcasecmp(months[i], RSTRING(v[1])->ptr) == 0) {
+		args[1] = i;
+		break;
+	    }
+	}
+	if (args[1] == -1) {
+	    char c = RSTRING(v[1])->ptr[0];
+
+	    if ('0' <= c && c <= '9') {
+		args[1] = NUM2INT(v[1])-1;
+	    }
+	}
+    }
+    else {
+	args[1] = NUM2INT(v[1]);
+    }
+    if (v[2] == Qnil) {
+	args[2] = 1;
+    }
+    else {
+	args[2] = NUM2INT(v[2]);
+    }
+    for (i=3;i<6;i++) {
+	if (v[i] == Qnil) {
+	    args[i] = 0;
+	}
+	else {
+	    args[i] = NUM2INT(v[i]);
+	}
+    }
+
+    /* value validation */
+    if (   args[0] < 70|| args[1] > 137
+	|| args[1] < 0 || args[1] > 11
+	|| args[2] < 1 || args[2] > 31
+	|| args[3] < 0 || args[3] > 23
+	|| args[4] < 0 || args[4] > 60
+	|| args[5] < 0 || args[5] > 61)
+	ArgError("argument out of range");
+}
+
+static VALUE
+time_gm_or_local(argc, argv, gm_or_local, class)
+    int argc;
+    VALUE *argv;
+    int gm_or_local;
+    VALUE class;
+{
+    int args[6];
+    struct timeval tv;
+    struct tm *tm;
+    time_t guess, t;
+    int diff;
+    struct tm *(*fn)();
+
+    fn = (gm_or_local) ? gmtime : localtime;
+    time_arg(argc, argv, args);
+
+    gettimeofday(&tv, 0);
+    guess = tv.tv_sec;
+
+    tm = (*fn)(&guess);
+    if (!tm) goto error;
+    t = args[0];
+    while (diff = t - tm->tm_year) {
+	guess += diff * 364 * 24 * 3600;
+	if (guess < 0) ArgError("too far future");
+	tm = (*fn)(&guess);
+	if (!tm) goto error;
+    }
+    t = args[1];
+    while (diff = t - tm->tm_mon) {
+	guess += diff * 27 * 24 * 3600;
+	tm = (*fn)(&guess);
+	if (!tm) goto error;
+    }
+    guess += (args[2] - tm->tm_mday) * 3600 * 24;
+    guess += (args[3] - tm->tm_hour) * 3600;
+    guess += (args[4] - tm->tm_min) * 60;
+    guess += args[5] - tm->tm_sec;
+
+    return time_new_internal(class, guess, 0);
+
+  error:
+    ArgError("gmtime error");
+}
+
+static VALUE
+time_s_timegm(argc, argv, class)
+    int argc;
+    VALUE *argv;
+    VALUE class;
+{
+    return time_gm_or_local(argc, argv, 1, class);
+}
+
+static VALUE
+time_s_timelocal(argc, argv, class)
+    int argc;
+    VALUE *argv;
+    VALUE class;
+{
+    return time_gm_or_local(argc, argv, 0, class);
+}
+
+static VALUE
+time_to_i(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    return int2inum(tobj->tv.tv_sec);
+}
+
+static VALUE
+time_to_f(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    return float_new((double)tobj->tv.tv_sec+(double)tobj->tv.tv_usec/1000000);
+}
+
+static VALUE
+time_usec(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    return INT2FIX(tobj->tv.tv_usec);
+}
+
+static VALUE
+time_cmp(time1, time2)
+    VALUE time1, time2;
+{
+    struct time_object *tobj1, *tobj2;
+    int i;
+
+    GetTimeval(time1, tobj1);
+    switch (TYPE(time2)) {
+      case T_FIXNUM:
+	i = FIX2INT(time2);
+	if (tobj1->tv.tv_sec == i) return INT2FIX(0);
+	if (tobj1->tv.tv_sec > i) return INT2FIX(1);
+	return FIX2INT(-1);
+	
+      case T_FLOAT:
+	{
+	    double t;
+
+	    if (tobj1->tv.tv_sec == (int)RFLOAT(time2)->value) return INT2FIX(0);
+	    t = (double)tobj1->tv.tv_sec + (double)tobj1->tv.tv_usec*1e-6;
+	    if (tobj1->tv.tv_sec == RFLOAT(time2)->value) return INT2FIX(0);
+	    if (tobj1->tv.tv_sec > RFLOAT(time2)->value) return INT2FIX(1);
+	    return FIX2INT(-1);
+	}
+    }
+
+    if (obj_is_instance_of(time2, cTime)) {
+	GetTimeval(time2, tobj2);
+	if (tobj1->tv.tv_sec == tobj2->tv.tv_sec) {
+	    if (tobj1->tv.tv_usec == tobj2->tv.tv_usec) return INT2FIX(0);
+	    if (tobj1->tv.tv_usec > tobj2->tv.tv_usec) return INT2FIX(1);
+	    return FIX2INT(-1);
+	}
+	if (tobj1->tv.tv_sec > tobj2->tv.tv_sec) return INT2FIX(1);
+	return FIX2INT(-1);
+    }
+    i = NUM2INT(time2);
+    if (tobj1->tv.tv_sec == i) return INT2FIX(0);
+    if (tobj1->tv.tv_sec > i) return INT2FIX(1);
+    return FIX2INT(-1);
+}
+
+static VALUE
+time_eql(time1, time2)
+    VALUE time1, time2;
+{
+    struct time_object *tobj1, *tobj2;
+
+    GetTimeval(time1, tobj1);
+    if (obj_is_instance_of(time2, cTime)) {
+	GetTimeval(time2, tobj2);
+	if (tobj1->tv.tv_sec == tobj2->tv.tv_sec) {
+	    if (tobj1->tv.tv_usec == tobj2->tv.tv_usec) return TRUE;
+	}
+    }
+    return FALSE;
+}
+
+static VALUE
+time_hash(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+    int hash;
+
+    GetTimeval(time, tobj);
+    hash = tobj->tv.tv_sec ^ tobj->tv.tv_usec;
+    return INT2FIX(hash);
+}
+
+static VALUE
+time_localtime(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+    struct tm *tm_tmp;
+
+    GetTimeval(time, tobj);
+    tm_tmp = localtime((const time_t*)&tobj->tv.tv_sec);
+    tobj->tm = *tm_tmp;
+    tobj->tm_got = 1;
+#ifndef HAVE_TM_ZONE
+    tobj->gmt = 0;
+#endif
+    return time;
+}
+
+static VALUE
+time_gmtime(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+    struct tm *tm_tmp;
+
+    GetTimeval(time, tobj);
+    tm_tmp = gmtime((const time_t*)&tobj->tv.tv_sec);
+    tobj->tm = *tm_tmp;
+    tobj->tm_got = 1;
+#ifndef HAVE_TM_ZONE
+    tobj->gmt = 1;
+#endif
+    return time;
+}
+
+static VALUE
+time_asctime(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+    char buf[64];
+    int len;
+
+    GetTimeval(time, tobj);
+    if (tobj->tm_got == 0) {
+	time_localtime(time);
+    }
+#ifndef HAVE_TM_ZONE
+    if (tobj->gmt == 1) {
+	len = strftime(buf, 64, "%a %b %d %H:%M:%S GMT %Y", &(tobj->tm));
+    }
+    else
+#endif
+    {
+	len = strftime(buf, 64, "%a %b %d %H:%M:%S %Z %Y", &(tobj->tm));
+    }
+    return str_new(buf, len);
+}
+
+static VALUE
+time_plus(time1, time2)
+    VALUE time1, time2;
+{
+    struct time_object *tobj1, *tobj2;
+    int sec, usec;
+
+    GetTimeval(time1, tobj1);
+    if (TYPE(time2) == T_FLOAT) {
+	unsigned int nsec = (unsigned int)RFLOAT(time2)->value;
+	sec = tobj1->tv.tv_sec + nsec;
+	usec = tobj1->tv.tv_usec + (RFLOAT(time2)->value - (double)nsec)*1e6;
+    }
+    else if (obj_is_instance_of(time2, cTime)) {
+	GetTimeval(time2, tobj2);
+	sec = tobj1->tv.tv_sec + tobj2->tv.tv_sec;
+	usec = tobj1->tv.tv_usec + tobj2->tv.tv_usec;
+    }
+    else {
+	sec = tobj1->tv.tv_sec + NUM2INT(time2);
+	usec = tobj1->tv.tv_usec;
+    }
+
+    if (usec >= 1000000) {	/* usec overflow */
+	sec++;
+	usec -= 1000000;
+    }
+    return time_new(sec, usec);
+}
+
+static VALUE
+time_minus(time1, time2)
+    VALUE time1, time2;
+{
+    struct time_object *tobj1, *tobj2;
+    int sec, usec;
+
+    GetTimeval(time1, tobj1);
+    if (obj_is_instance_of(time2, cTime)) {
+	double f;
+
+	GetTimeval(time2, tobj2);
+	f = tobj1->tv.tv_sec - tobj2->tv.tv_sec;
+
+	f += (tobj1->tv.tv_usec - tobj2->tv.tv_usec)*1e-6;
+
+	return float_new(f);
+    }
+    else if (TYPE(time2) == T_FLOAT) {
+	sec = tobj1->tv.tv_sec - (int)RFLOAT(time2)->value;
+	usec = tobj1->tv.tv_usec - (RFLOAT(time2)->value - (double)sec)*1e6;
+    }
+    else {
+	sec = tobj1->tv.tv_sec - NUM2INT(time2);
+	usec = tobj1->tv.tv_usec;
+    }
+
+    if (usec < 0) {		/* usec underflow */
+	sec--;
+	usec += 1000000;
+    }
+    return time_new(sec, usec);
+}
+
+static VALUE
+time_sec(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    if (tobj->tm_got == 0) {
+	time_localtime(time);
+    }
+    return INT2FIX(tobj->tm.tm_sec);
+}
+
+static VALUE
+time_min(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    if (tobj->tm_got == 0) {
+	time_localtime(time);
+    }
+    return INT2FIX(tobj->tm.tm_min);
+}
+
+static VALUE
+time_hour(time)
+    VALUE time;
+{
+    struct time_object *tobj;
+
+    GetTimeval(time, tobj);
+    if ( (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]